Subchapter 13.3
cost-forecast/examples.mdMarkdown3 KBView on GitHub
Common forecast patterns with request bodies. Use the SKILL.md workflow to construct and execute the az rest command.
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "<first-of-month>",
"to": "<last-of-month>"
},
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"sorting": [
{ "direction": "Ascending", "name": "UsageDate" }
]
},
"includeActualCost": true,
"includeFreshPartialCost": true
}💡 Tip: Set
fromto the first of the month — the response containsActualrows up to today andForecastrows for remaining days.
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "<first-of-month>",
"to": "<3-months-out>"
},
"dataset": {
"granularity": "Monthly",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"sorting": [
{ "direction": "Ascending", "name": "BillingMonth" }
]
},
"includeActualCost": true,
"includeFreshPartialCost": true
}💡 Tip: Monthly granularity uses the
BillingMonthcolumn in the response.
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "<start-date>",
"to": "<end-date>"
},
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"sorting": [
{ "direction": "Ascending", "name": "UsageDate" }
]
},
"includeActualCost": true,
"includeFreshPartialCost": true
}💡 Tip: Scope is set at the URL level. Use the resource group scope URL to limit the forecast.
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "<start-date>",
"to": "<end-date>"
},
"dataset": {
"granularity": "Monthly",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"sorting": [
{ "direction": "Ascending", "name": "BillingMonth" }
]
},
"includeActualCost": true,
"includeFreshPartialCost": true
}💡 Tip: Use URL pattern
/providers/Microsoft.Billing/billingAccounts/<id>/.... Monthly granularity recommended for billing account forecasts.
| Scope | URL Pattern |
|---|---|
| Subscription | /subscriptions/<subscription-id>/providers/Microsoft.CostManagement/forecast |
| Resource Group | /subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.CostManagement/forecast |
| Billing Account | /providers/Microsoft.Billing/billingAccounts/<id>/providers/Microsoft.CostManagement/forecast |
💡 Tip: These are path-only patterns — not complete URLs. Append
?api-version=2023-11-01when constructing the full request URL.