Microsoft Azure · Delivery

Cost Management

Cloud bills grow quietly. A few habits keep Azure spending predictable and low.

Advanced 5 min Lesson 26 of 28
0/28 in Microsoft Azure
On this page · 5 min · Advanced

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#

ShellA monthly budget with alerts Illustrative
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
Expected output
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#

  1. The budget covers one resource group for a year, in your billing currency.
  2. Alert thresholds and recipients are then configured on the budget (easily in the portal).
  3. 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#

No budget until the first big bill

Create budgets before creating resources.

Buying reservations too early

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
Shell Illustrative
az network public-ip list --query "[?ipConfiguration==null].{Name:name, RG:resourceGroup}" -o table

Mini quiz#

Cost Management quizTrue or false Question 1 of 1

A VM that is stopped from inside the OS (not deallocated) stops billing for compute.

Score so far: 0/0

Want more? Practise all Microsoft Azure MCQs · Microsoft Azure interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.