@Admin (KK) You would need to use Usage Details, pull the data to your side and filter the data to what you need.
Issue with Cost Managment cli command
Hello, I am trying to run an az cli command to get the total cost of all the resources which has tag and when i run the below script i am getting the following error. can someone help me in fix this.
$billingScope = "subscriptions/xxxx"
az costmanagement query --type "Usage" --dataset-aggregation '{\"totalCost\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}'
--dataset-grouping name="ResourceId" type="Dimension" --timeframe "MonthToDate" --scope "$billingScope" `
--dataset-filter '{\"tag\":{\"name\":\"Environment\",\"operator\":\"In\",\"values\":[\"UAT\",\"Prod\"]}}'
Error Message :
az : ERROR: (BadRequest) Invalid query definition: Invalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.
At line:2 char:1
- az costmanagement query --type "Usage"`
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (ERROR: (BadRequ...tag can be set.:String) [], RemoteException
- FullyQualifiedErrorId : NativeCommandError
(Request ID: ff49a644-1bf6-4806-b28c-e8232fd40a80)
Code: BadRequest
Message: Invalid query definition: Invalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.
(Request ID: ff49a644-1bf6-4806-b28c-e8232fd40a80)
1 answer
Sort by: Most helpful
-
SadiqhAhmed-MSFT 45,271 Reputation points Microsoft Employee
2022-03-14T06:08:57.317+00:00