I am using Azure Consumption Usage API to calculate the cost for a resource over a certain span of time, in the response received the cost and effectivePrice value is "0" for every record.
Here is my full url:
GET "https://management.azure.com/subscriptions/{subscriptionsId}/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2019-08-07T00:00:00Z' and properties/usageEnd le '2019-08-09T01:00:00Z'&api-version=2019-05-01"
Here is the response format:
{ "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 analysis is disabled by the Admin of the subscription, is it why the every record in the response has "cost":0 and "effectivePrice":0 ?
How I can get the cost for a resource using Consumption API?
Can I use the quantity and unitPrice to get the cost for that particular response record?