1

I am trying to retrieve the total cost of a subscription for a given month (let's say last month).

I tried using ComputeManagementClient but I always end up with a whole list of usage details, even when I use a filter in the following way :

c_client = ConsumptionManagementClient(creds, sub_id)
startDate = '2019-03-01T00:00:00Z'
endDate = '2019-03-31T23:59:59Z'
filt = "usageStart eq {} and usageEnd eq {}".format(startDate, endDate)
result = c_client.usage_details.list(filter=filt)
...

What am I doing wrong ? Do I have to iterate through pages and calculate the total cost by myself ?

EDIT : Thanks to @Joy Wang answer, I get further. But now I end up with daily usage details from the current month instead of last month - whereas I am sure that this subscription was running last month. Any idea ?

Jul_DW
  • 1,036
  • 6
  • 20

1 Answers1

3

It seems you should use properties/usageStart and properties/usageEnd instead of usageStart and usageEnd.

See this link:

enter image description here

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
  • I think that was indeed a mistake, thanks. But I still have an issue, I end up with usage details on a daily basis from the current month - from `2019-04-01T00:00:00Z` to `2019-04-01T23:59:59Z` and then `2019-04-02T00:00:00Z` to `2019-04-02T23:59:59Z`. (while I can retrieve data from March on the portal - manually). Any idea ? – Jul_DW Apr 15 '19 at 11:45
  • @Jul_DW Not sure, may be related to the time zone? I recommend you to post another question to ask it. – Joy Wang Apr 15 '19 at 12:54