1

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!

David Aleu
  • 3,922
  • 3
  • 27
  • 48
  • 1
    Is there a continuation token being returned in the response headers? If so the results are being paged and you need to request the next page. –  Feb 02 '16 at 09:09
  • Thanks @AndyJ, you should post your comment as an answer to accept it :) – David Aleu Feb 03 '16 at 12:43

2 Answers2

1

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.

0

As per @AndyJ suggestion, I have fixed this using the continuationToken parameter in my api request (see below). Passing the continuationToken value from each response will give you the next set of data until the last "page" where continuationToken will be empty meaning the data for the selected range is all completed.

providers/Microsoft.Commerce/UsageAggregates?api-version=2015-06-01-preview&reportedstartTime=2016-01-01&reportedEndTime=2016-02-01&aggregationGranularity=Daily&showDetails=true&continuationToken=" + continuationToken
David Aleu
  • 3,922
  • 3
  • 27
  • 48