Microsoft Cost Management (in the portal): cost analysis (spend by service, resource group, tag), budgets (alerts at thresholds), recommendations (Azure Advisor) and exports of cost data to storage.
Tags
A tag is a name=value pair on a subscription, resource group or resource, for example env=dev, owner=devops, costcenter=cc-1001. Use tags to filter and roll up costs in cost analysis. Tags are not folders: there is no hierarchy, and resources do not inherit resource-group tags automatically (use the Azure Policy "Inherit a tag from the resource group").
flowchart LR RG["rg-devops-lab<br/>env=dev, owner=devops"] --> V["vm-web-01<br/>env=dev"] RG --> S["stdevopslab<br/>env=dev"] V --> CA["Cost analysis<br/>group by tag env"] S --> CA
CLI notes:
- az group update -n rg-devops-lab --tags env=dev owner=devops replaces all tags of the group with the new list.
- az tag update --resource-id <id> --operation Merge --tags costcenter=cc-1001 adds/changes tags and keeps the old ones (Replace and Delete are the other modes).
Saving money
| Option | Meaning |
|---|---|
| Reservations | Commit for 1 or 3 years on VMs, SQL… for big discounts |
| Azure Hybrid Benefit | Reuse existing Windows Server/SQL Server licences (with Software Assurance) |
| Dev/test credits | Monthly credits from Visual Studio subscriptions for dev/test |
| Pick regions, stop idle resources | Prices differ by region; stop/deallocate VMs outside working hours |
| Command | Meaning |
|---|---|
az group update -n rg-devops-lab --tags env=dev owner=devops |
Reset the resource group tags |
az tag update --resource-id ... --operation Merge --tags k=v |
Add a tag, keep the old ones |
Tag rules worth knowing
- A resource, resource group, or subscription can hold up to 50 tag pairs.
- Tag names are case-insensitive for lookups, values are case-sensitive, so agree on one spelling such as
env=prod. - Some older resource types do not support tags, and tags are stored as plain text, so never put secrets in them.
- Enforce required tags with Azure Policy (
Require a tag on resources) rather than relying on memory.
A small, fixed tag set, for example env, owner, costcenter, and app, is far more useful than many inconsistent ones.
Estimating before you build
The Azure pricing calculator estimates the monthly cost of a planned design. The TCO calculator compares running a workload on-premises with running it in Azure. Prices vary by region, tier, and commitment, so record your assumptions next to an estimate.
Acting on cost data
| Tool | Use |
|---|---|
| Budgets | Email or trigger an action group at, say, 80% and 100% of a monthly amount |
| Anomaly alerts | Notify you when daily spend jumps unexpectedly |
| Azure Advisor | Recommendations in cost, security, reliability, performance, and operational excellence |
| Auto-shutdown | Stop a dev VM every evening |
A budget only alerts; it does not stop resources by itself unless you connect an automation to its action group.
More ways to pay less
Azure savings plan for compute gives a discount for a fixed hourly spend across VM sizes and regions, more flexible than reservations. Spot VMs use spare capacity at a large discount but can be evicted at short notice, which suits batch jobs and CI agents, never production databases. Right-size VMs that run at low CPU, and delete unattached disks and old snapshots.