I used this https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list.
I tried to filter usage details by properties/resourceGroup, properties/usageStart, properties/usageEnd, properties/chargeType but I always get the same data for the current month(11/2020) for CSP subscriptions.
Also I always receive"costInBillingCurrency": 0 and "costInPricingCurrency": 0.
Expectation: Get data for previous month with costInBillingCurrency or costInPricingCurrency other than 0.
Example(I have changed some GUIDs and names) json:
{
"value": [
{
"kind": "modern",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails/0954c228-20f0-fbbc-fe83-c89392a148d1",
"name": "0954c228-20f0-fbbc-fe83-c89392a148d1",
"type": "Microsoft.Consumption/usageDetails",
"tags": null,
"properties": {
"additionalInfo": "",
"billingAccountId": "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30",
"billingAccountName": "",
"billingCurrencyCode": "USD",
_"billingPeriodEndDate": "0001-01-01T00:00:00Z",_ //strange
_"billingPeriodStartDate": "0001-01-01T00:00:00Z",_ //strange
"billingProfileId": "",
"billingProfileName": "",
"chargeType": "Usage",
"consumedService": "Microsoft.Insights",
"costInBillingCurrency": 0,
"costInPricingCurrency": 0,
"costCenter": "",
"date": "2020-11-19T00:00:00Z",
"exchangeRate": "1",
"exchangeRateDate": "2020-11-01T00:00:00Z",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/mrg/providers/Microsoft.Insights/metricAlerts/VIA-SuccessE2ELatency-cs25914ae19e2c4x4ceaxb62",
"invoiceId": "",
"invoiceSectionId": "",
"invoiceSectionName": "",
"isAzureCreditEligible": "1",
"meterCategory": "Azure Monitor",
"meterId": "00000000-0000-0000-0000-000000000000",
"meterName": "Alerts Metrics Monitored",
"meterRegion": "",
"meterSubCategory": "Azure Monitor",
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Azure Monitor - Alerts",
"productIdentifier": "000000000000",
"productOrderId": "00000000-0000-0000-0000-000000000000",
"productOrderName": "Azure plan",
"publisherName": "Microsoft",
"publisherType": "Azure",
"quantity": 0.0322580645161291,
"resourceGroup": "mrg",
"resourceLocation": "GLOBAL",
"resourceLocationNormalized": "Unknown",
"serviceFamily": "Management and Governance",
"serviceInfo1": "",
"serviceInfo2": "",
"servicePeriodEndDate": "2020-12-01T00:00:00Z",
"servicePeriodStartDate": "2020-11-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "CSP",
"unitOfMeasure": "1/Month",
"unitPrice": 0.1,
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"customerName": "name",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"partnerName": "name",
"resellerMpnId": "000000",
"resellerName": "",
"publisherId": "",
"reservationId": "",
"reservationName": "",
"frequency": "UsageBased",
"term": "",
"payGPrice": 0.1,
"costInUSD": 0,
"paygCostInBillingCurrency": 0,
"paygCostInUSD": 0,
"exchangeRatePricingToBilling": 1,
"partnerEarnedCreditRate": 0,
"partnerEarnedCreditApplied": "1"
}
}
]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ms-premp.
Issue Details
I used this https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list.
I tried to filter usage details by properties/resourceGroup, properties/usageStart, properties/usageEnd, properties/chargeType but I always get the same data for the current month(11/2020) for CSP subscriptions.
Also I always receive"costInBillingCurrency": 0 and "costInPricingCurrency": 0.
Expectation: Get data for previous month with costInBillingCurrency or costInPricingCurrency other than 0.
Example(I have changed some GUIDs and names) json:
{
"value": [
{
"kind": "modern",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails/0954c228-20f0-fbbc-fe83-c89392a148d1",
"name": "0954c228-20f0-fbbc-fe83-c89392a148d1",
"type": "Microsoft.Consumption/usageDetails",
"tags": null,
"properties": {
"additionalInfo": "",
"billingAccountId": "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30",
"billingAccountName": "",
"billingCurrencyCode": "USD",
_"billingPeriodEndDate": "0001-01-01T00:00:00Z",_ //strange
_"billingPeriodStartDate": "0001-01-01T00:00:00Z",_ //strange
"billingProfileId": "",
"billingProfileName": "",
"chargeType": "Usage",
"consumedService": "Microsoft.Insights",
"costInBillingCurrency": 0,
"costInPricingCurrency": 0,
"costCenter": "",
"date": "2020-11-19T00:00:00Z",
"exchangeRate": "1",
"exchangeRateDate": "2020-11-01T00:00:00Z",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/mrg/providers/Microsoft.Insights/metricAlerts/VIA-SuccessE2ELatency-cs25914ae19e2c4x4ceaxb62",
"invoiceId": "",
"invoiceSectionId": "",
"invoiceSectionName": "",
"isAzureCreditEligible": "1",
"meterCategory": "Azure Monitor",
"meterId": "00000000-0000-0000-0000-000000000000",
"meterName": "Alerts Metrics Monitored",
"meterRegion": "",
"meterSubCategory": "Azure Monitor",
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Azure Monitor - Alerts",
"productIdentifier": "000000000000",
"productOrderId": "00000000-0000-0000-0000-000000000000",
"productOrderName": "Azure plan",
"publisherName": "Microsoft",
"publisherType": "Azure",
"quantity": 0.0322580645161291,
"resourceGroup": "mrg",
"resourceLocation": "GLOBAL",
"resourceLocationNormalized": "Unknown",
"serviceFamily": "Management and Governance",
"serviceInfo1": "",
"serviceInfo2": "",
"servicePeriodEndDate": "2020-12-01T00:00:00Z",
"servicePeriodStartDate": "2020-11-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "CSP",
"unitOfMeasure": "1/Month",
"unitPrice": 0.1,
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"customerName": "name",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"partnerName": "name",
"resellerMpnId": "000000",
"resellerName": "",
"publisherId": "",
"reservationId": "",
"reservationName": "",
"frequency": "UsageBased",
"term": "",
"payGPrice": 0.1,
"costInUSD": 0,
"paygCostInBillingCurrency": 0,
"paygCostInUSD": 0,
"exchangeRatePricingToBilling": 1,
"partnerEarnedCreditRate": 0,
"partnerEarnedCreditApplied": "1"
}
}
]
| Author: | Nikolay-Uvarov |
|---|---|
| Assignees: | lirenhe |
| Labels: | `Consumption`, `Service Attention`, `needs-triage`, `question` |
| Milestone: | - |
I think this is related to issue #11849 I've just raised - manually adding the query parameters startDate and endDate to the URL has the desired effect, but those are not documented in this spec.
when there is no date filters passed in the request the calls defaults to current month charges(aka open month costs). To get the data for specific month use this requesturl should work for a
modern subscription
https://management.azure.com/subscriptions/_{{yourSubscriptionId}}_/providers/Microsoft.Consumption/usageDetails?api-version=2019-11-01&startDate=2020-10-01&endDate=2020-10-03
for a legacy subscription
https://management.azure.com/subscriptions/_{{yourSubscriptionId}}_/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2020-11-01' and properties/usageEnd le '2020-11-03'&api-version=2019-10-01
$filter is not supported for the modern subscription calls. @adwise3 we need to update the documentation for this.
@tujamg I am still getting "costInBillingCurrency": 0, "costInPricingCurrency": 0
Can you please share the requestId for the requests you made?
Can you please share the requestId for the requests you made?
"name":"dd383151-ba9a-cf98-d57e-8adba22678ee",
"name":"c726eb4f-e513-a8fb-6cf0-c40e079ffee8".
or for the second one
x-ms-request-id: 03056d65-1b64-4160-b458-819ce8ce0d43
@tujamg Hi! Do you have any updates?
Hello @tujamg, @adwise3,
Do you have any updates to the issue?
I have a similar question about the not worked $filter parameter. I use this doc: https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list#uri-parameters, but it still describes $filter. Could you advise any updated doc on how to apply filtering to a request?
How can we filter by any property that is not related to dates (e.g. properties/consumedService)? Is it possible to filter by tags now?
Thanks.
I will check and have folks respond on this. Thanks!
$filter is only supported for legacy Azure channels (Enterprise Agreement, Web Direct) - NOT for modern channels.
Modern billing scopes consist of:
• Billing Account
• Billing Profile (aka Billing Group)
• Invoice Section (aka Project)
• Customer (for partners)
Modern subscriptions have an offer type that end with a 'G' (e.g. 0017G)
Legacy billing scopes consist of:
• Enrollment (aka Billing Account)
• Department
• Account (aka Enrollment Account)
Legacy subscriptions have an offer type that end with a 'P' (e.g. 0017P, 0003P).
Usage Details - List
The public docs for the Sync Usage Details API are here…
https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list#uri-parameters
This includes this information…
May be used to filter usageDetails by
• properties/resourceGroup
• properties/resourceName
• properties/resourceId
• properties/chargeType
• properties/reservationId
• properties/publisherType - accepts two values 'azure' and 'marketplace' and it is currently supported for Web Direct offers
• tags - a key value pair string where key and value is separated by a colon (:)
There is additional public documentation here:
https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/manage-automation#get-usage-details-for-a-scope-during-specific-date-range
That says:
The data that's returned by the request corresponds to the date when the usage was received by the billing system. It might include costs from multiple invoices. Please note that the call you make will vary depending on if you are a Legacy or Modern customer.
Legacy customers (EA and Pay-As-You-Go Legacy):
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?$filter=properties%2FusageStart%20ge%20'2020-02-01'%20and%20properties%2FusageEnd%20le%20'2020-02-29'&$top=1000&api-version=2019-10-01
Modern Customers (Microsoft Customer Agreement):
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?startDate=2020-08-01&endDate=&2020-08-05$top=1000&api-version=2019-10-01
@Nikolay-Uvarov - Are there any further questions/clarifications you have?
Most helpful comment
when there is no date filters passed in the request the calls defaults to current month charges(aka open month costs). To get the data for specific month use this requesturl should work for a
modern subscription
https://management.azure.com/subscriptions/_{{yourSubscriptionId}}_/providers/Microsoft.Consumption/usageDetails?api-version=2019-11-01&startDate=2020-10-01&endDate=2020-10-03
for a legacy subscription
https://management.azure.com/subscriptions/_{{yourSubscriptionId}}_/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2020-11-01' and properties/usageEnd le '2020-11-03'&api-version=2019-10-01
$filter is not supported for the modern subscription calls. @adwise3 we need to update the documentation for this.