Search code examples
azure-billing-api

Azure Billing API gives me only 7 days of data


Is there any restriction on the date range to use the Azure Billing API? I'm requesting a month's worth of data but I only get the first 7 days of that range...

I use a request like the one below:

/UsageAggregates?api-version=2015-06-01-preview&reportedstartTime=2015-12-01&reportedEndTime=2016-01-01

And my console only gives me:

[2015-12-01T00:00:00+00:00] Metric 1 blah blah
[2015-12-01T00:00:00+00:00] Metric 2 blah blah
[2015-12-01T00:00:00+00:00] Metric 3 blah blah
[2015-12-02T00:00:00+00:00] Metric 1 blah blah
[2015-12-02T00:00:00+00:00] Metric 2 blah blah
[2015-12-02T00:00:00+00:00] Metric 3 blah blah
[2015-12-03T00:00:00+00:00] Metric 1 blah blah
[2015-12-03T00:00:00+00:00] Metric 2 blah blah
[2015-12-03T00:00:00+00:00] Metric 3 blah blah
[2015-12-04T00:00:00+00:00] Metric 1 blah blah
[2015-12-04T00:00:00+00:00] Metric 2 blah blah
[2015-12-04T00:00:00+00:00] Metric 3 blah blah
[2015-12-05T00:00:00+00:00] Metric 1 blah blah
[2015-12-05T00:00:00+00:00] Metric 2 blah blah
[2015-12-05T00:00:00+00:00] Metric 3 blah blah
[2015-12-06T00:00:00+00:00] Metric 1 blah blah
[2015-12-06T00:00:00+00:00] Metric 2 blah blah
[2015-12-06T00:00:00+00:00] Metric 3 blah blah
[2015-12-07T00:00:00+00:00] Metric 1 blah blah
[2015-12-07T00:00:00+00:00] Metric 2 blah blah
[2015-12-07T00:00:00+00:00] Metric 3 blah blah

And that's all I get!


Solution

  • Many of the Azure REST APIs use continuation tokens to provide pagination of results.

    The Billing API is rather new and the documentation is thin on the ground, but here's an example of continuation token based pagination with the Azure Tables REST API.

    If your results are being paged then you should see a header in the HTTP response providing the token to get the next page of results.