Azure消费使用明细API响应的每条记录都有“成本”:0和“有效价格”:0

时间:2019-09-10 04:01:05

标签: azure api

我正在使用Azure消耗使用API​​计算特定时间段内资源的成本,在收到的响应中,每条记录的成本和有效价格值为“ 0”。

这是我的完整网址:

  

获取“ https://management.azure.com/subscriptions/ {subscriptionsId} /providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge'2019-08-07T00:00:00Z'和properties / usageEnd le'2019-08- 09T01:00:00Z'&api-version = 2019-05-01“

以下是响应格式:

  

{ "value": [ { "id":"/subscriptions/{subscriptionsId}/providers/Microsoft.Billing/billingPeriods/20190901/providers/Microsoft.Consumption/usageDetails/######-####-####-####-##########", "name":"######-####-####-####-##########", "type":"Microsoft.Consumption/usageDetails", "tags":null, "properties": { "billingAccountId":"*******", "billingAccountName":"*****************", "billingPeriodStartDate":"2019-09-01T00:00:00.0000000Z", "billingPeriodEndDate":"2019-09-30T00:00:00.0000000Z", "billingProfileId":"******", "billingProfileName":"************************", "accountOwnerId":"**********", "accountName":"*************", "subscriptionId":"subscriptioId", "subscriptionName":"subscriptionName", "date":"2019-09-06T00:00:00.0000000Z", "product":"Product Name", "partNumber":"******", "meterId":"meterId", "quantity":0.004032, "effectivePrice":0, "cost":0, "unitPrice":0.045, "billingCurrency":"USD", "resourceLocation":"EastUS", "consumedService":"microsoft.web", "resourceId":"/subscriptions/......", "resourceName":"resourceName", "invoiceSection":"Unassigned", "resourceGroup":"resourceGroupName", "offerId":"MS-AZR-0017P", "isAzureCreditEligible":true, "publisherType":"Azure", "chargeType":"Usage", "frequency":"UsageBased", "meterDetails":null } } ] }

订阅管理员禁用了成本分析,这就是为什么响应中的每个记录都具有“ cost”:0和“ effectivePrice”:0的原因?

enter image description here

如何使用Consumption API获取资源成本?

我可以使用数量和单价来获取该特定响应记录的成本吗?

1 个答案:

答案 0 :(得分:0)

我想你不能。在门户中单击Cost analysis时,它还会调用Azure管理REST API(其前缀为https://management.azure.com/)。

因此,如果您的订阅中禁用了费用,您将无法通过直接调用REST API来访问它,也无法通过其他方法(例如本质上调用REST API的azure powershell,cli)进行访问。

相关问题