People would use Invoke-AzCostManagementQuery to retrieve cost information, but the listed examples do not return any actual cost data. This is due to the way the underlying API is designed: if you don't request any aggregations, then you just get empty response rows.
For contrast, here's an API request as sent by the Azure Portal. Notice the aggregation property.
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000
Type of issue
Code doesn't work
Feedback
People would use
Invoke-AzCostManagementQuery
to retrieve cost information, but the listed examples do not return any actual cost data. This is due to the way the underlying API is designed: if you don't request anyaggregation
s, then you just get empty response rows.For contrast, here's an API request as sent by the Azure Portal. Notice the
aggregation
property.Mimicking that API call, here's an example for
Invoke-AzCostManagementQuery
that does return cost data:Could you update the docs to list more helpful examples?
Related: #20749
Page URL
https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery?view=azps-12.3.0&viewFallbackFrom=azps-10.4.1
Content source URL
https://github.com/Azure/azure-powershell/blob/main/src/CostManagement/CostManagement/help/Invoke-AzCostManagementQuery.md
Author
@mikefrobbins
Document Id
3dff2f6a-7cc0-e478-2079-8a417fc895dd