Setting Budgets and Cost Alerts in Azure
Budgets and cost alerts are your early warning system against unexpected cloud spend. Azure Cost Management lets you set spending thresholds at any scope — subscription, resource group, or tag — and notify stakeholders or trigger automated actions before a billing surprise lands in your inbox.
How Azure Budgets Work
An Azure budget is a spending threshold applied to a specific scope. When actual or forecast spend crosses a percentage of that threshold, Azure fires an alert. Budgets reset monthly, quarterly, or annually depending on how you configure them.
There are two alert types within a budget:
- Actual cost alerts: fire when cumulative spend in the period crosses a threshold percentage (e.g., 80% of budget). These are retrospective — money has already been spent.
- Forecasted cost alerts: fire when Azure’s spend projection indicates you will cross a threshold by the end of the period. These give you warning days before you actually overspend.
Budget alerts do not automatically stop resources. They send notifications. If you want automated remediation, you must attach an action group that triggers an Azure Automation runbook or Azure Function to take action.
Creating a Budget in the Azure Portal
In the Azure portal, search for Cost Management + Billing and open it.
In the left menu, select Cost Management then Budgets.
Verify the scope shown at the top is correct (subscription, resource group, or management group). Click Change scope if needed.
Click + Add.
Fill in the budget details:
- Name: give it a descriptive name like
prod-monthly-budget - Reset period: Monthly, Quarterly, Annually, or Billing month
- Creation date and expiration date: set an end date at least 12 months out
- Amount: the total budget for the period in your billing currency
- Name: give it a descriptive name like
Click Next: Alerts.
Add alert conditions. You can add up to five thresholds per budget. A typical configuration:
- 50% actual — information only
- 80% actual — notify finance team
- 90% forecasted — notify team leads
- 100% actual — escalate to manager
For each threshold, specify an action group (for automated responses) or enter email addresses directly.
Click Create.
Creating Budgets with the Azure CLI
CLI-based budget creation is useful for automation, infrastructure-as-code pipelines, and managing budgets across multiple subscriptions programmatically.
# Get your subscription ID
SUBSCRIPTION_ID=$(az account show --query id -o tsv)
# Create a monthly budget of $500 on a subscription
az consumption budget create \
--budget-name "prod-monthly-500" \
--amount 500 \
--time-grain Monthly \
--start-date "2026-04-01" \
--end-date "2027-04-01" \
--resource-group-filter "" \
--category Cost
# Note: Portal creation is recommended for adding alert thresholds and action groups
# as the CLI budget create command has limited support for alert conditions.
# Use the REST API or Bicep for full alert configuration.Creating a budget with Bicep
resource monthlyBudget 'Microsoft.Consumption/budgets@2023-05-01' = {
name: 'prod-monthly-budget'
properties: {
timePeriod: {
startDate: '2026-04-01'
endDate: '2027-04-01'
}
timeGrain: 'Monthly'
amount: 500
category: 'Cost'
notifications: {
actualSpend80: {
enabled: true
operator: 'GreaterThanOrEqualTo'
threshold: 80
thresholdType: 'Actual'
contactEmails: [
'finance@yourcompany.com'
'teamlead@yourcompany.com'
]
}
forecastedSpend90: {
enabled: true
operator: 'GreaterThanOrEqualTo'
threshold: 90
thresholdType: 'Forecasted'
contactEmails: [
'teamlead@yourcompany.com'
]
}
actualSpend100: {
enabled: true
operator: 'GreaterThanOrEqualTo'
threshold: 100
thresholdType: 'Actual'
contactEmails: [
'manager@yourcompany.com'
'finance@yourcompany.com'
]
}
}
}
}Automated Responses with Action Groups
Action groups let you wire budget alert notifications to automated actions. When a threshold is crossed, the action group can:
- Send email notifications to one or more addresses
- Send an SMS message
- Post to a webhook (useful for Slack or Teams notifications)
- Trigger an Azure Automation runbook (to stop VMs or scale down resources)
- Trigger an Azure Logic App workflow
- Call an Azure Function
Example: auto-stop dev VMs at 100% of budget
# First, create an Automation account and runbook that stops VMs
# Then create an action group that triggers the runbook
# Create the action group
az monitor action-group create \
--resource-group cost-management-rg \
--name "stop-dev-vms" \
--short-name "StopDevVMs" \
--action email finance finance@yourcompany.com
# The Automation runbook triggered by the action group:
# (PowerShell runbook in Azure Automation)
# param([object]$WebhookData)
# $vms = Get-AzVM -ResourceGroupName "dev-rg"
# foreach ($vm in $vms) {
# Stop-AzVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name -Force
# }For development environments, automating VM shutdown at budget thresholds is a low-risk, high-impact approach to cost control. Dev VMs that are inadvertently left running overnight or over weekends are one of the most common sources of unnecessary cloud spend.
Cost Anomaly Alerts
Beyond budget thresholds, Azure Cost Management includes anomaly detection that identifies unusual spending patterns using machine learning. Unlike budget alerts which fire when cumulative spend crosses a level, anomaly alerts fire when a day’s spending is significantly higher than expected based on your historical patterns.
Anomaly alerts can detect:
- A forgotten VM that was left running after a test
- An accidental deployment of expensive GPU VMs
- Runaway storage costs from a misconfigured logging pipeline
- Unusual data egress from a potential security incident
# Cost anomaly alerts are configured in the portal under
# Cost Management > Anomaly alerts
# There is no direct CLI command; use the REST API:
az rest \
--method PUT \
--url "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/scheduledActions/daily-anomaly-alert?api-version=2023-11-01" \
--body '{
"kind": "InsightAlert",
"properties": {
"displayName": "Daily cost anomaly alert",
"status": "Enabled",
"notification": {
"to": ["finance@yourcompany.com"],
"subject": "Azure Cost Anomaly Detected"
},
"schedule": {
"frequency": "Daily",
"dayOfWeek": "Monday"
}
}
}'Budget Strategy Across Environments
In most organisations, you will want separate budgets for production, staging, and development environments. A practical approach is to use resource group-scoped budgets rather than subscription-level budgets, which gives you finer visibility:
| Environment | Recommended Budget Scope | Suggested Thresholds | Action at 100% |
|---|---|---|---|
| Production | Subscription or resource group | 80% actual, 90% forecast, 100% actual | Notify, no auto-stop |
| Staging | Resource group | 70% actual, 90% actual | Notify team lead |
| Development | Resource group per team | 80% actual, 100% actual | Auto-stop non-essential VMs |
| Per project | Tag-based filter | 90% actual | Notify project owner |
Common Mistakes
- Setting one subscription-level budget and nothing else. A single top-level budget tells you when you have overspent overall but gives no visibility into which team or project caused it. Layer budgets from subscription level down to resource group or tag level.
- Only setting actual-cost thresholds. Actual-cost alerts fire after money is already spent. Always add at least one forecasted-cost threshold so you have advance warning before the period ends.
- Not reviewing budget amounts after the first billing cycle. Set your initial budget based on estimates, then review it after the first full month and adjust based on actual patterns. Budgets set too high provide false comfort; budgets set too low generate constant noise.
- Sending all alerts to the same email. Route different threshold levels to different audiences. A 50% notification might go to a developer; a 100% notification should go to a manager and finance.
Summary
- Azure budgets are spending thresholds that trigger alerts when actual or forecasted costs cross configured percentages.
- Budgets can be scoped to subscription, resource group, management group, or filtered by tag — use layered budgets for environment-level visibility.
- Action groups enable automated responses (VM shutdown, webhook notifications) when thresholds are crossed.
- Cost anomaly alerts complement budgets by detecting unusual day-to-day spending patterns using machine learning.
Frequently asked questions
Does an Azure budget automatically stop resources when the limit is reached?
By default, Azure budgets are alerts-only — they do not stop or delete resources when a threshold is crossed. You can configure budget action groups to trigger Azure Automation runbooks or Logic Apps that stop VMs or scale down resources automatically.
How quickly do budget alerts fire after a threshold is crossed?
Azure evaluates budget thresholds approximately every 24 hours for actual cost alerts. Forecasted alerts may trigger earlier if the projected end-of-period spend crosses the threshold. There is no real-time alerting for cost; for tighter controls, use cost anomaly alerts which can detect unusual patterns within hours.
Can I create budgets scoped to a specific resource group or tag?
Yes. Budgets can be scoped to a subscription, resource group, management group, or filtered by resource type, resource group, tag, or meter category. Narrow scoping is useful for tracking costs for a specific project or team.