Azure consumption API for past months

Prasad, Rakesh 221 Reputation points
2022-02-21T15:49:12.857+00:00

hello,

i am using following API to get usage details, but have following issue.

GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2021-10-01

1) I cannot get run this API for past period.

2) API just gives data for current month, so either I run this API at 23:59:00 on last day of the month, or else i will miss some stats.

3) can I run this API for past months? if not, then what is a way to get same details for earlier period.

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,049 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. SadiqhAhmed-MSFT 38,081 Reputation points Microsoft Employee
    2022-02-22T16:13:38.98+00:00

    Hello @Prasad, Rakesh - Thank you for contacting us!

    I know that you are looking for balance summary for previous months. Currently, this is a limitation for Balance Summary in Power BI.

    Below is PG advise:

    The call by Billing Account Balances - Get By Billing Account - REST API (Azure Consumption) | Microsoft Learn gives current month data only.

    To get data for other billing periods, please use this API Balances - Get For Billing Period By Billing Account - REST API (Azure Consumption) | Microsoft Learn

    Hope this helps!

    ----------------------------------------------------------------------------------------------------------------------

    If the response helped, do "Accept Answer" and up-vote it

    0 comments No comments

  2. Madi 1 Reputation point
    2022-08-05T15:09:20.467+00:00

    @SadiqhAhmed-MSFT can you please help me to get the Consumption usage details of previous month.

    I used this API to fetch the usage details of scope but it only return the record of the current month.

    https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2021-10-01

    Then, I used this api to fetch the balances:
    https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{id}/providers/Microsoft.Consumption/balances?api-version=2021-10-01

    But, get this response:
    {"error":{"code":"404","message":"No billing period information found for the specified Enrollments}

    Can, you please help me to fetch the usage details for previous months.