订阅中的Azure使用率和资源成本

时间:2019-07-08 15:23:33

标签: python azure azure-sdk azure-sdk-python

是否可以使用Azure Python SDK [https://docs.microsoft.com/en-us/python/api/overview/azure/?view=azure-python]来获取单个资源的成本?

我已经使用RateCard [https://docs.microsoft.com/en-us/python/api/azure-mgmt-commerce/azure.mgmt.commerce.operations.ratecardoperations?view=azure-python]和Usage [https://docs.microsoft.com/en-us/python/api/azure-mgmt-commerce/azure.mgmt.commerce.operations.usageaggregatesoperations?view=azure-python] API来计算费用。但是正在寻找更好的解决方案。

query = "OfferDurableId eq '" + offer_id + \
                "' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'"
ratecard = usage_client.rate_card.get(filter=query)

usage = usage_client.usage_aggregates.list(reported_start_time=start,
                                                                 reported_end_time=end,
                                                                 show_details=True,
                                                                 aggregation_granularity="Daily"):

使用Azure SDK获取最近30天的单个资源费用。

0 个答案:

没有答案