简体   繁体   English

使用Python SDK检索Azure订阅的上个月费用

[英]Retrieving last month cost of an Azure subscription using Python SDK

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 : 我尝试使用ComputeManagementClient但即使使用以下方式使用过滤器,我也总是最终得到用法详细信息的完整列表:

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. 编辑:感谢@Joy Wang的答复,我走得更远。 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 ? 任何想法 ?

It seems you should use properties/usageStart and properties/usageEnd instead of usageStart and usageEnd . 似乎您应该使用properties/usageStartproperties/usageEnd而不是usageStartusageEnd

See this link : 看到这个链接

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM