Cost Management
Cloud bills grow quietly. A few habits keep Azure spending predictable and low.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Analyse costs by service and tag
- Create budgets and alerts
- Find and remove waste
- Understand reservations and savings plans
Explanation#
Cost Management + Billing shows spending by service, resource group, tag and time. Forecasts warn you before the month ends.
Budgets send alerts at thresholds (for example 50%, 80% and 100%) and can trigger automation.
Common waste: running dev VMs at night, oversized plans, unattached disks, idle public IPs and forgotten test resource groups.
For steady workloads, reservations (1 or 3 years for a specific resource type) and Azure savings plans for compute (a committed hourly spend) offer large discounts compared with pay-as-you-go.
Code example: A monthly budget with alerts#
az consumption budget create --budget-name budget-shop-dev \
--amount 2000 --category cost --time-grain monthly \
--start-date 2026-11-01 --end-date 2027-10-31 \
--resource-group rg-shop-dev
# Find unattached managed disks (paid but unused)
az disk list --query "[?diskState=='Unattached'].{Name:name, SizeGB:diskSizeGb, RG:resourceGroup}" -o table
Name SizeGB RG ----------------- ------ ------------ vm-old_OsDisk_1 30 rg-learn
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- The budget covers one resource group for a year, in your billing currency.
- Alert thresholds and recipients are then configured on the budget (easily in the portal).
- The disk query lists disks no VM is using — still billed every month.
Real-world use case#
A startup tags every resource by team and environment, gets a weekly cost email, and auto-stops dev environments outside office hours — cutting its bill substantially.
Common mistakes#
Create budgets before creating resources.
Commit only for workloads with stable, proven usage.
Best practices#
- Set budgets and alerts on every subscription
- Tag everything with owner and environment
- Review Azure Advisor cost recommendations monthly
- Auto-shutdown or scale down non-production
Remember this#
Budget first, resources second.
Idle ≠ free: disks, IPs and stopped-but-allocated VMs still cost.
Steady workload → reservations or savings plans.
Practice exercise#
Your task: List all public IP addresses not attached to anything.
Show solution
az network public-ip list --query "[?ipConfiguration==null].{Name:name, RG:resourceGroup}" -o table
Mini quiz#
A VM that is stopped from inside the OS (not deallocated) stops billing for compute.
Want more? Practise all Microsoft Azure MCQs · Microsoft Azure interview questions
My notes#
Saved in this browser.