budget-health
Budget Health Check
Quick answer to the three questions users actually ask about a budget: Am I over? Will I overshoot? Is anything firing?
Steps
-
List Budgets — Call
list_budgetswith the user's scope.- If no budgets exist on the scope, skip to the No budgets found handoff below.
- If the call returns an access-denied error, the user lacks Cost Management read access on this scope — surface that distinctly rather than reporting it as "no budgets found."
-
End-of-Month Forecast — Call
forecast_costswith the same scope. It returns one row per day, each taggedCostStatusActualorForecast, and the same date can appear as both. For the month-end projection, take one value per date — theActualif present, otherwise theForecast— and sumPreTaxCost. Compare that to the budget amount.- No Forecast rows? If the response has only
Actualrows, a projection isn't available for this scope — report month-to-date actual and say a forecast couldn't be produced; don't present partial actuals as a month-end projection. This happens on multi-currency scopes (below) and where there's too little history to project. - Multi-currency caveat: the Cost Management Forecast API doesn't return a forecast for scopes that span multiple currencies — a management group or billing account can mix, e.g., USD and GBP, in which case the response comes back as
Actual-only rows per currency. Re-scope to a single-currency subscription to get a forecast, and never sum across currencies.
- No Forecast rows? If the response has only
-
Current Month Spend — Call
query_costswith timeframe=MonthToDate, groupBy=ServiceName, granularity=None for the spend breakdown by service. If it returns no rows (early in the billing cycle, before current-month data is available), say so rather than implying zero spend — optionally repeat with timeframe=TheLastMonth for recent context.- Multi-currency caveat: at management-group or billing-account scope, the result may contain multiple
Currencyvalues. Group by Currency before summing or comparing — don't combine USD and GBP into one total. - Source-of-truth note: for the budget % use
list_budgets'currentSpend.amount(this is what Azure evaluates Actual-cost budget alerts against; Forecasted alerts evaluate againstforecastSpend). Use thequery_costsMTD result only for the service-level drill-down.
- Multi-currency caveat: at management-group or billing-account scope, the result may contain multiple
-
Active Alerts — Call
list_alertsto surface triggered budget or anomaly alerts. Each alert carries aperiodStartDateand stays inActivestatus until dismissed, so the list can include alerts from earlier months. CheckperiodStartDate: present only current-period alerts as firing now, and label older ones as prior-period history.