Azure 6: Cost Management & Budgets
easy⏱ 5 mincourseazure
Azure Cost Management
Azure Cost Management provides cost analysis, budgets, alerts, and recommendations. Budgets set spending limits with alerts at thresholds (e.g., 80%, 100%). Tags are critical for cost attribution — tag resources by team, project, or environment.
// Azure CLI: Create a budget
az consumption budget create \
--budget-name MonthlyBudget --amount 1000 \
--time-grain monthly --category cost
Build a cost tracker
Create a CostTracker class that can addResource(name, dailyCost), setBudget(amount), and checkBudget(days) which calculates projected monthly cost and returns an alert level (ok, warning at 80%, critical at 100%). Log the budget status.
Quiz: Budget Alerts
When does Azure stop your resources if you exceed your budget? It doesn't — budgets are informational only. They send notifications but do not stop services. To enforce spending limits, use resource quotas or Azure Policy.