Monitor and Optimize Azure Spending
Beginner8 minTrending
Query current costs, set budgets with alerts, and identify cost-saving opportunities using Azure CLI cost management commands.
Prerequisites
- -Azure CLI installed
- -Cost Management Reader role or higher
Steps
1
View current month costs by resource group
Shows a breakdown of costs by resource for the current billing period.
$ az consumption usage list --start-date 2026-03-01 --end-date 2026-03-11 --query "[].{Name:instanceName, Cost:pretaxCost, Currency:currency}" --output table
2
Create a monthly budget
Sets a $500 monthly budget scoped to a specific resource group.
$ az consumption budget create --budget-name monthly-limit --amount 500 --time-grain Monthly --start-date 2026-03-01 --end-date 2026-12-31 --resource-group myapp-rg
3
List active budgets
Displays all configured budgets and their current spend.
$ az consumption budget list --output table
4
Get cost optimization recommendations
Azure Advisor surfaces actionable cost-saving recommendations such as resizing or shutting down underutilized resources.
$ az advisor recommendation list --category cost --output table
Review advisor recommendations weekly for the biggest savings opportunities.
5
Check reservation recommendations
Shows recommended reserved instance purchases based on your usage patterns.
$ az consumption reservation recommendation list --scope Shared --output table
Full Script
FAQ
Discussion
Loading comments...