Skip to content
Visual explainer 2h 30m to learn 5 steps

Attribute and reduce Azure spend

Break spend down by resource and tag and cut idle services, egress, log retention and over-provisioning.

By Invicly Tech, , in Microsoft Azure Cloud Engineering. About 14 minutes to read.

Topic 25 of 33

In short

Cost optimisation starts with attribution: you cannot cut what you cannot assign to an owner. Cost Management breaks spend down by subscription, resource group, service and tag, so you can find idle resources, heavy egress, oversized log ingestion and autoscale floors set too high. Only after trimming waste should you commit to reservations or a savings plan for the steady baseline that remains.

Think of it like this: Read the itemised bill before you sign a phone contract: first cancel what you do not use, then commit to the plan that fits what is left.

Explained simply

Cloud bills grow quietly. A test database left running, a disk from a deleted VM, or logs collected at full detail can each add a little every day. Cost optimisation is the habit of finding out where money goes, cutting what gives no value, and only then committing to discounts for what remains.

The first step is knowing who owns each cost. Azure Cost Management shows spend by subscription, resource group, service and tag. A tag is a label such as env=prod or owner=payments. If resources are tagged well, you can answer questions like how much does the checkout team spend in production.

The next step is finding waste. Common examples are idle resources (unattached disks, unused public IPs, empty App Service plans), data leaving Azure (egress), logs you collect but never read, and apps that keep too many copies running at night. Azure Advisor lists many of these for free.

Finally, for the steady part of your usage that runs all the time, you can commit for one or three years and pay less. Reservations commit to a specific resource type in a region. Savings plans commit to an hourly spend that can move between compute services. Commit only after cleaning up, or you lock in the waste.

Press Play on a diagram to walk through it one step at a time.

CycleThe cost review loop
  1. 1
    Attribute

    Tag resources and group cost by tag and resource

  2. 2
    Find waste

    Idle resources, egress, log volume, oversized tiers

  3. 3
    Fix

    Delete, resize, lower floors, shorten retention

  4. 4
    Commit

    Reserve or commit only the steady baseline

  5. 5
    Watch

    Budgets and anomaly alerts catch drift

  6. Back to step 1
MapWhere a typical small workload's money goes
Monthly spend for one app
  • Compute
    • Container Apps replicas
    • App Service plan instances
    • VMs and their disks
  • Data
    • Database vCores and storage
    • Backups and snapshots
    • Blob storage and transactions
  • Networking
    • Internet egress
    • Cross-region transfer
    • Public IPs, gateways, firewalls
  • Operations
    • Log Analytics ingestion
    • Retention beyond included days
    • Defender plans

In depth

Attribution with tags and scopes

Cost analysis can group by subscription, resource group, resource, meter, service and tag. Resource groups are the simplest owner boundary, so give each workload and environment its own. Tags add dimensions that cut across groups, such as cost-center or app. Resources do not inherit tags from their resource group by default; use Azure Policy (for example the built-in policies that add or inherit a tag) to apply them at creation, and turn on tag inheritance in Cost Management so usage records pick up subscription and resource group tags. Tags only affect cost data from the time they exist, so tagging late leaves a gap. Some charges, such as certain marketplace or support costs, cannot be tagged at all. Report untagged spend as its own line so it shrinks over time.

  • Minimum tags: app, env, owner, cost-center
  • Enforce with policy at the management group
  • Enable tag inheritance in Cost Management
  • Track untagged spend as a number

Idle and oversized resources

Idle spend hides in resources that keep billing after their purpose ends. Managed disks and snapshots bill by provisioned size even when no VM uses them. Standard public IP addresses bill per hour whether attached or not. A VM shut down from inside the operating system still reserves and bills its compute; it must be stopped (deallocated) from Azure. An App Service plan bills for its instances even with no apps in it. Oversizing is the other half: a database at 5 percent CPU or a premium tier used for a dev site. Azure Advisor flags low-utilisation VMs and other right-size candidates. Check utilisation over at least two weeks, including month-end peaks, before resizing.

  • Unattached disks and old snapshots
  • Unassociated public IPs
  • Stopped but not deallocated VMs
  • Empty App Service plans
  • Dev environments on production tiers

Egress and log retention

Inbound data to Azure is free. Data out to the internet is charged per gigabyte after a monthly free allowance, and data between regions is charged too. Reduce egress by serving static files through a CDN such as Azure Front Door with caching, compressing responses, keeping an app and its database in the same region, and avoiding cross-region chatter in normal operation. For logs, ingestion is usually the larger cost: Log Analytics bills per gigabyte ingested, then for retention beyond the included period (31 days for most tables, 90 days for Application Insights tables). Cut ingestion first: choose diagnostic categories carefully, lower app log levels, use sampling, and move verbose tables to the cheaper Basic plan. Then set retention per table and use long-term retention for audit data you rarely query.

LayersLevers on a Log Analytics bill, biggest first
  1. 1
    Collect less

    Fewer diagnostic categories, lower log levels, sampling

  2. 2
    Cheaper table plan

    Basic or Auxiliary for verbose, rarely queried data

  3. 3
    Commitment tier

    Discount when ingestion is steady and large

  4. 4
    Retention per table

    Short interactive retention, long-term for audit

  5. 5
    Daily cap

    Safety net for runaway ingestion, not a plan

Autoscale floors

Autoscale adds capacity when load rises, but the minimum count runs all the time. On Container Apps, a minimum of 0 replicas lets an idle app scale to zero and stop paying for active compute, at the price of a cold start on the first request. A minimum of 2 keeps two replicas warm for availability. App Service bills per plan instance, so a plan with a minimum of 3 instances pays for 3 around the clock. Set floors per environment: production keeps enough for zone redundancy and peak start-up, while dev and test can scale to zero or a single instance and shut down outside working hours. Review floors after launches, because the cautious launch-day setting often stays forever.

Reservations versus savings plans

Both trade a one or three year commitment for a lower price, and both can be paid upfront or monthly. A reservation applies to one resource type, such as a VM size family or a database's vCores, in one region; the discount is larger, but it is wasted if that exact usage disappears. A savings plan for compute commits to a fixed hourly spend and applies automatically across eligible compute, such as virtual machines and some App Service and Container Apps plans, in any region; the discount is usually smaller but follows your workload when it changes. Cover only the steady baseline, the usage you see every hour of the month, and leave peaks on pay-as-you-go. Check utilisation reports monthly.

CompareCommitment choices
Pay-as-you-go
  • No commitment
  • Highest unit price
  • Best for peaks and experiments
Reservation
  • Specific resource type and region
  • Usually the deepest discount
  • Best for stable, predictable usage
  • Wasted if usage moves away
Savings plan for compute
  • Fixed hourly spend commitment
  • Applies across eligible compute and regions
  • Smaller discount, more flexible
  • Best when the mix will change

Learn it in 5 short steps

About 30m each. Track them with a timer in your plan.

  1. 1
    Analyse costs by tag~30m
  2. 2
    Find idle resources~30m
  3. 3
    Reduce egress and log retention~30m
  4. 4
    Tune autoscale floors~30m
  5. 5
    Compare reservations and savings plans~30m

Key points

  • Tags only appear on cost from the day they are applied; tag at creation time with policy.
  • Stopped virtual machines still bill for compute unless they are deallocated; disks and public IPs bill until deleted.
  • Data out of Azure to the internet and between regions costs money; data in is free.
  • Log Analytics bills mainly by ingested gigabytes, so filter what you collect before shortening retention.
  • Reservations fit one resource type in one region; savings plans trade some discount for flexibility across compute.

Key terms

Tap a card to flip it. 0/6 known

Examples

bash
# unattached managed disks (still billed every month)
az disk list --query "[?diskState=='Unattached'].{name:name, rg:resourceGroup, gb:diskSizeGb}" -o table
# public IPs not attached to anything
az network public-ip list --query "[?ipConfiguration==null].{name:name, rg:resourceGroup}" -o table
# VMs that are stopped but not deallocated
az vm list -d --query "[?powerState=='VM stopped'].{name:name, rg:resourceGroup}" -o table
# Advisor cost recommendations
az advisor recommendation list --category Cost -o table

Four quick read-only checks for common idle spend.

A monthly cost review for the sample app (illustrative numbers)

Prices here are invented for the exercise; check the pricing calculator for real ones. Step 1: group last month by tag app. Checkout costs 1,200 a month, plus 300 untagged. Step 2: the untagged 300 is two old snapshots (40) and a test VM stopped from inside Windows (260), still billing compute. Deallocate or delete them: saves 300. Step 3: Log Analytics ingests 60 GB a month at 2.50 per GB = 150. Container console logs are 40 GB at debug level; switching to info cuts them to 8 GB, saving 80. Step 4: the dev Container Apps environment keeps 2 replicas all night; setting minimum replicas to 0 saves an estimated 90. Total: about 470 of 1,500, roughly 31 percent, before any commitment.

Sizing a commitment for the remaining baseline

After cleanup, the production VMs for a legacy service run 4 identical instances all month, and a fifth runs only during business hours. Step 1: the baseline is 4 instances. Step 2: compare options using illustrative prices: pay-as-you-go 100 per VM per month, a 1-year reservation at 60, a 1-year savings plan equivalent to 70. Step 3: the team plans to move this service to Container Apps within the year, so a reservation for the VM size could be stranded. Choose the savings plan, since it would also apply to eligible compute later. Commit to 4 x 70 = 280 a month equivalent hourly spend; the fifth VM stays pay-as-you-go. Saving: 400 - 280 = 120 a month.

text
Baseline VMs        4 x 24h x 30d
Pay-as-you-go       4 x 100 = 400 / month
Reservation (1y)    4 x 60  = 240 / month  (VM size + region locked)
Savings plan (1y)   4 x 70  = 280 / month  (flexible across compute)
Peak VM             1 x 100 x (10/24 h) = about 42 / month, stays PAYG

Quick reference

  • Tag at creation with policy: app, env, owner, cost-center; tags do not backfill old usage
  • Stopped is not deallocated: only Stopped (deallocated) ends VM compute charges
  • Unattached disks, snapshots and Standard public IPs bill until deleted
  • Inbound data is free; internet egress and cross-region transfer are charged
  • Log Analytics: cut ingestion first, then set retention per table
  • Container Apps minimum replicas 0 lets idle apps scale to zero
  • Commit only the steady baseline; reservations are specific, savings plans flexible
  • Set budgets with alerts at 50, 80 and 100 percent per subscription or resource group

Common mistakes

  • Buying a three year reservation before right-sizing, which locks in the waste.
  • Shortening log retention while ingestion, the larger cost, stays unchanged.
  • Setting every environment's minimum replicas to production values, so dev pays for idle capacity.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A resource group was tagged with app=checkout yesterday. What does cost analysis show for last month?

Question 2

2Which of these keeps billing compute charges?

Question 3

3Your Log Analytics bill is mostly ingestion. What should you change first?

Question 4

4Which data transfer is normally free in Azure?

Question 5

5Your compute will move from VMs to Container Apps next year. Which commitment fits better?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    List idle disks and public IPs in your lab subscription and delete the ones you no longer need.

  2. Exercise 2medium

    Create a monthly budget of 50 for your lab resource group with an email at 80 percent, and enforce an env tag on new resources with policy.

  3. Exercise 3hard

    A workload's Log Analytics ingestion is 300 GB a month. Find the top tables by volume and design a plan to cut it by half without losing alerting data.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Where do I see what Azure is costing me right now?
In the portal under Cost Management, Cost analysis. Data is usually delayed by several hours, so use budgets and anomaly alerts rather than watching it live.
Does a budget stop my resources when I reach it?
No. A budget only sends alerts. You can attach an action group to run automation, but nothing is stopped automatically unless you build that.
Can I cancel a reservation if I no longer need it?
Reservations can be exchanged or cancelled under Microsoft's current policy, which has limits and may change. Check the current terms before buying, and only commit to usage you are confident about.
What is the cheapest way to run a lab?
Use a free account or a sandbox subscription, put everything in one resource group, set a budget, prefer consumption or scale-to-zero services, and delete the resource group when you finish.

Go deeper

ShareXLinkedInWhatsApp