Not able to get Azure Billing Account Id

1.8k Views Asked by At

I need to get Usage Details at Billing Account Scope for that firstly I used this API but It returns an empty value. I used the Bearer Access token for hitting this API.Is anything other than this am I missed?

Postman Request attached as screenshot

Postman Request attached as screenshot

2

There are 2 best solutions below

0
On BEST ANSWER

This api will return a value if account belongs to Modern billing

10
On

I believe you're using the wrong API. To get Billing info you must provide billing account name:

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}?api-version=2019-10-01-preview

https://learn.microsoft.com/en-us/rest/api/billing/2019-10-01-preview/billingaccounts/get

PS: you can use the "try it" and test if it will return the information you need.

You can also query usage API and use one of the available dimensions to get cost related info:

POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2019-11-01

https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage