MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.1k stars 21.15k forks source link

Resource group scope does not work as documented #38660

Open AndrewGailer opened 4 years ago

AndrewGailer commented 4 years ago

When using the Usage Details - List REST API, specifying a scope with a resource group returns a 404 - File or directory not found error.

The documentation says to specify the scope as /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName} but this returns the 404 error.

As a workaround, you can specify the resource group in the filter like $filter=properties/resourceGroup eq '{resourceGroupName}'; however, this does not work with the latest version of the API (2019-05-01). If you specify the filter, the following error is returned:

{
    "error": {
        "code": "400",
        "message": "Billing Period is not supported in (2019-05-01) API Version for Subscription Scope With Web Direct Offer. (Request ID: adf9d616-cc8f-48c9-84eb-8fa59d528170)"
    }
}

Changing the API version to the previous stable release (2019-01-01) allows the filter to work. This is an example of the full URI: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2019-05-01&$filter=properties/resourceGroup eq 'dev-rg'

Document Details ⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: 77db9ac7-6b1c-496b-36a3-24119c897546 Version Independent ID: 31fbb3ed-1eb8-ff0c-05d8-1e92ccc1519f Content: Azure consumption API overview Content Source: articles/billing/billing-consumption-api-overview.md Service: billing GitHub Login: @bandersmsft Microsoft Alias: banders

KrishnaG-MSFT commented 4 years ago

@AndrewGailer Thanks for the comment. This feedback has been shared with @bandersmsft for further review.

prajyot2909 commented 4 years ago

I am also facing the same issue do we have any resolution on the above question ?

ClintFrancis commented 4 years ago

I'm getting the same error when making a call to the Usage Details List with the 2019-10-01 API:

https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2019-10-01

Results in the error:

{"code":"400","message":"Billing Period is not supported in (2019-10-01) API Version for Subscription Scope With Web Direct Offer. (Request ID: 69e0e402-d3fd-49a3-b7d8-728f272aa51d)"}

Making the same call using the 2019-01-01 API is successful, but is not in line with the documentation and is missing fields (resourceGroup etc).

Any resolution?

josch83 commented 4 years ago

@bandersmsft Are there any news on this issue? It still returns "Billing Period is not supported in (2019-11-01) API Version for Subscription Scope With Web Direct Offer. (Request ID: 69fda2f6-f14b-4202-8b6e-6f906a1d9a8b)" for subscription-based scopes. Even worse, the previously usable api-version "2019-01-01" started to return an empty array only. Edit: The api-version "2019-01-01" now again delivers content (seems that there was just a temporary unavailability).

muad81 commented 4 years ago

Same issue here : Billing Period is not supported in (2019-10-01) API Version for Subscription Scope. Latest working version at Subscription scope is 2019-01-01. Is there any ways to query this last version?

yaegashi commented 4 years ago

I got the same error with go-autorest for https://management.azure.com/subscriptions/XXXXXXXX/providers/Microsoft.Consumption/usageDetails?&api-version=2019-10-01:

consumption.UsageDetailsClient#List: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="400" Message="Billing Period is not supported in (2019-10-01) API Version for Subscription Scope With Web Direct Offer. Please provide the UsageStart and UsageEnd dates in the $filter key as parameters. (Request ID: adcd9582-23c2-4d11-a53c-698b4a4845b8)"

I didn't provide any billing periods in the request. And how can I provide UsageStart and UsageEnd dates for usagedetails?

yaegashi commented 4 years ago

It worked with the following query: $filter=properties/usageStart eq '2020-06-01' and properties/usageEnd eq '2020-06-30' as seen in https://github.com/Azure/azure-sdk-for-go/issues/2399#issuecomment-467212692

https://management.azure.com/subscriptions/XXXXXXXX/providers/Microsoft.Consumption/usageDetails?%24expand=properties%2FadditionalInfo%2Cproperties%2FmeterDetails&%24filter=properties%2FusageStart+eq+%272020-06-01%27+and+properties%2FusageEnd+eq+%272020-06-30%27&api-version=2019-10-01

The doc should be updated to mention the correct $filter spec for Web Direct Offer.

bandersmsft commented 3 years ago

@KrishnaG-MSFT This issue doesn't directly affect the article published to https://docs.microsoft.com/azure/cost-management-billing/manage/consumption-api-overview

This appears to be a bug with https://docs.microsoft.com/rest/api/consumption/usagedetails/list and that's maintained by the engineering team. Can please reassign as a product bug, not a doc issue? Thanks.

Tom331 commented 3 years ago

Hi @bandersmsft, is there a workaround or an ETA on the product bug fix? I am having a similar issue with the usageDetails endpoint, specifically i cannot filter on tags in the $filter parameter. Stack overflow question with the problem I'm having

KrishnaG-MSFT commented 3 years ago

Unable to add @prkumarms-zz in assignees so tagging @prkumarms-zz for visibility, review and to help provide insights.

PcChip commented 3 years ago

Hello,

I'm having the same error message with Az consumption usage list, I cannot pull any usage info https://github.com/Azure/azure-powershell/issues/10203

Tom331 commented 3 years ago

@PcChip Hey, i found a workaround. If you check out the comment i made in my stack overflow post it may help:

https://stackoverflow.com/questions/63125218/azure-usagedetails-rest-api-cannot-filter-on-tags

ankur198 commented 2 years ago

apparently adding quotes in the filter fixes the issue

not working: costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq {end_date} and properties/usageStart eq {start_date}")

working: costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq '{end_date}' and properties/usageStart eq '{start_date}'")

DeBlackDragon commented 2 years ago

Still don´t working within newer api-versions. Just 2019-01-01 seems to acceppt the parameters. @ankur198 also tried the qoutes around the parameters but makes no difference

doruchiulan commented 1 year ago

Having issues too, trying to use tags in combination with startDate/endDate does not work, giving always empty result

https://management.azure.com/subscriptions/{{subscriptionId}}/providers/Microsoft.Consumption/usageDetails?api-version=2021-10-01&$filter=tags eq 'vendor:databricks' and properties/usageStart ge '2022-11-01' and properties/usageEnd le '2022-11-10'