-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
Cost Management - QueryAll issues in cost management and Consumption for query API associated to tags, dimensions and forecAll issues in cost management and Consumption for query API associated to tags, dimensions and forecDoc - ReferenceService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.customer-reported
Description
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 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": "ActualCost",
"dataSet": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "Cost",
"function": "Sum"
},
"totalCostUSD": {
"name": "CostUSD",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroupName"
},
{
"type": "Dimension",
"name": "ChargeType"
},
{
"type": "Dimension",
"name": "PublisherType"
}
]
},
"timeframe": "Custom",
"timePeriod": {
"from": "2024-09-01T00:00:00+00:00",
"to": "2024-09-30T23:59:59+00:00"
}
}Mimicking that API call, here's an example for Invoke-AzCostManagementQuery that does return cost data:
Invoke-AzCostManagementQuery -Scope /subscriptions/00000000-0000-0000-0000-000000000000 -Timeframe MonthToDate -Type ActualCost -DatasetGranularity 'Monthly' -DatasetAggregation @{ 'totalCost' = @{ 'name' = 'Cost' } }
Column Row
------ ---
{Cost, BillingMonth, Currency} {1.54425705929919 01 Sept 2024 00:00:00 EUR}
Could you update the docs to list more helpful examples?
Related: #20749
Page URL
Content source URL
Author
Document Id
3dff2f6a-7cc0-e478-2079-8a417fc895dd
Metadata
Metadata
Assignees
Labels
Cost Management - QueryAll issues in cost management and Consumption for query API associated to tags, dimensions and forecAll issues in cost management and Consumption for query API associated to tags, dimensions and forecDoc - ReferenceService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.customer-reported