Azure Enterprise Usage API

Azure Enterprise Usage API

As an Azure Enterprise customer, you get to see our entire organizations billing data at One can log into the portal and after selecting the appropriate enrollment number, view the billing summary information across months and also download detailed usage report. The detailed usage report is really detailed to the level of individual billing records for each resource.

One can see the cost data in also, but this is limited to the subscriptions one has access to and also one really needs to look at each subscription individually.

For our work we were extracting the usage data from the EA portal, using the usage API as described on this page. There are multiple different formats of the API, so pick the appropriate one as per our need. We had started off with the API that returns JSON data for specific date range.{enrollmentNumber}/usagedetailsbycustomdate?startTime=2017-01-01&endTime=2017-01-10

This worked well for us for a while, but as the data volume increased this started to give us timeout exception. The reason was the design of the API and how is returns data. This API returns data is page sizes of 1000 records and the last entry is another URL which you need to then query to, to get the next 1000 records. Our data become so huge that we had to make hundreds of calls to the API to get the data we were interested in. Making so many calls to the same API in quick succession resulted in the server believing that it is under DDoS attack and it throttled our requests, causing timeouts.

We eventually had to shift to the Asynchronous CSV approach and are now using the following API{enrollmentNumber}/usagedetails/submit?startTime=2017-04-01&endTime=2017-04-10

The response has a reportURL, that needs to be polled further till the status is 1 or 2. Status = 3 is success and data is available and status values from 4 to 7 indicate different kinds of errors. The data is made available in a blob and is available there for 1 hour. You need to make a local copy of the file so that you can continue to work with it.

When we queried for the immediate previous day, we got error, in one of our client scenarios. We had to raise a ticket with Microsoft to get that resolved. Things are working fine now.

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.