0
votes

I want to automatically get the Billing Invoice details of my Azure Resource-group on a monthly basis using the Schedule Export feature in Azure Cost-Management. I'm able to create a monthly export. However, I'm not able to get the entire month's invoice details. Eg. Oct2020, Nov2020, Dec2020.

Instead this is the format in which my invoice is getting exported -->

Billing invoice period

This doesn't prove to be useful to me because I need to get the billing and invoice details for the entire month. And the invoice should automatically be exported monthly. Eg. Oct2020 then next -> Nov2020 then next -> Dec2020, so on & so forth.

Any advise on how to achieve this? Thanks in advance!

1
I think you can use rest API to create a monthly export. For more details, please refer to docs.microsoft.com/en-us/rest/api/cost-management/exports/…Jim Xu
Thanks so much @JimXuSD4
@JimXu Is there a way to get the Total cost of the month using the Rest Api monthly export?SD4
Because when we call export API, the dataset granularity must be 'Daily'. But when we call query API, it can be 'none' then it will return total cost.Jim Xu
Hi The query api cannot do recurrence, we need to call the API manually or create a schedule-task to call the API. Regarding how to call query API, please refer to docs.microsoft.com/en-us/rest/api/cost-management/query/usageJim Xu

1 Answers

1
votes

As you mentioned, the scheduled exports doesn’t support invoice-wise data export. However, here is what you can do:

  • Use Azure Cost Management Query API to generate the usage for the invoice period using the custom timeframe value.
  • Convert the JSON response to CSV.
  • Export the file to Storage Account.

Currently, the Query API supports grouping up to 10 dimensions. If you need the complete dataset, you can use Usage List API instead of Query API. In the Usage List API, you can specify the start and end date (as per your invoice) using the $filter parameter. Rest of the process is same.