Azure Consumption Usage API - Filter Not Working

1.1k views Asked by At

I have an issue trying to filter usages for Azure Consumption, as specified in the official documentation, based on:

properties/resourceName eq '{resourceName}

The complete URI is:

$ConsumtionUsagesUri = "https://management.azure.com/subscriptions/$subId/providers/Microsoft.Billing/billingPeriods/$BillingPeriod/providers/Microsoft.Consumption/usageDetails?$expand=meterDetails,additionalProperties&$filter=properties/resourceName eq '{resourceName}'&api-version=2019-10-01"

The query returns all the results regardless of filter. Thanks everyone for your help!

2

There are 2 answers

2
DonDave On

This may be because your syntax is not correct. If you would like to filter by resource name, you have to follow this syntax. Please note that the case sensitivity may return different result.

properties/instanceName eq '{instanceName}'

For other syntax, please check the Azure Consumption API repo. I believe this will work with Azure Consumption API.

0
Rakesh Prasad On

it will be like => ?api-version=2021-10-01&$expand=meterDetails&metric=amortizedcost&$filter=tags/Vendor eq '******'

API documentation is not correct.