Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Analyze Azure subscriptions to find cost savings via orphaned resources, rightsizing, and usage data
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
cost-forecast/examples.md
1# Forecast API Examples23Common forecast patterns with request bodies. Use the [SKILL.md workflow](../SKILL.md) to construct and execute the `az rest` command.45## 1. Forecast Rest of Current Month (Daily)67```json8{9"type": "ActualCost",10"timeframe": "Custom",11"timePeriod": {12"from": "<first-of-month>",13"to": "<last-of-month>"14},15"dataset": {16"granularity": "Daily",17"aggregation": {18"totalCost": { "name": "Cost", "function": "Sum" }19},20"sorting": [21{ "direction": "Ascending", "name": "UsageDate" }22]23},24"includeActualCost": true,25"includeFreshPartialCost": true26}27```2829> ๐ก **Tip:** Set `from` to the first of the month โ the response contains `Actual` rows up to today and `Forecast` rows for remaining days.3031---3233## 2. Forecast Next 3 Months (Monthly)3435```json36{37"type": "ActualCost",38"timeframe": "Custom",39"timePeriod": {40"from": "<first-of-month>",41"to": "<3-months-out>"42},43"dataset": {44"granularity": "Monthly",45"aggregation": {46"totalCost": { "name": "Cost", "function": "Sum" }47},48"sorting": [49{ "direction": "Ascending", "name": "BillingMonth" }50]51},52"includeActualCost": true,53"includeFreshPartialCost": true54}55```5657> ๐ก **Tip:** Monthly granularity uses the `BillingMonth` column in the response.5859---6061## 3. Forecast for Resource Group Scope6263```json64{65"type": "ActualCost",66"timeframe": "Custom",67"timePeriod": {68"from": "<start-date>",69"to": "<end-date>"70},71"dataset": {72"granularity": "Daily",73"aggregation": {74"totalCost": { "name": "Cost", "function": "Sum" }75},76"sorting": [77{ "direction": "Ascending", "name": "UsageDate" }78]79},80"includeActualCost": true,81"includeFreshPartialCost": true82}83```8485> ๐ก **Tip:** Scope is set at the URL level. Use the resource group scope URL to limit the forecast.8687---8889## 4. Forecast for Billing Account Scope9091```json92{93"type": "ActualCost",94"timeframe": "Custom",95"timePeriod": {96"from": "<start-date>",97"to": "<end-date>"98},99"dataset": {100"granularity": "Monthly",101"aggregation": {102"totalCost": { "name": "Cost", "function": "Sum" }103},104"sorting": [105{ "direction": "Ascending", "name": "BillingMonth" }106]107},108"includeActualCost": true,109"includeFreshPartialCost": true110}111```112113> ๐ก **Tip:** Use URL pattern `/providers/Microsoft.Billing/billingAccounts/<id>/...`. Monthly granularity recommended for billing account forecasts.114115---116117## Scope URL Reference118119| Scope | URL Pattern |120|---|---|121| Subscription | `/subscriptions/<subscription-id>/providers/Microsoft.CostManagement/forecast` |122| Resource Group | `/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.CostManagement/forecast` |123| Billing Account | `/providers/Microsoft.Billing/billingAccounts/<id>/providers/Microsoft.CostManagement/forecast` |124125> ๐ก **Tip:** These are path-only patterns โ not complete URLs. Append `?api-version=2023-11-01` when constructing the full request URL.126