Azure Pricing & Cost Management
Optimize Your Cloud Spending
Table of Contents
- Azure Pricing Overview
- Understanding Your Bill
- Cost Management Tools
- Azure Calculators
- Cost Optimization Strategies
- Reserved Instances & Savings Plans
- Budgets & Alerts
- Best Practices
1. Azure Pricing Overview
How Azure Pricing Works:
Azure uses a pay-as-you-go model where you only pay for what you use. Pricing varies by:
- Resource type (VM, Storage, Database)
- Region (Some regions are more expensive)
- Service tier (Basic, Standard, Premium)
- Usage volume (More usage = potential discounts)
- Reservation (Pre-paid = lower rates)
Pricing Components:
┌─────────────────────────────────────────────────────────────────┐
│ AZURE PRICING FACTORS │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ Compute │ │ Storage │ │ Network │ │
│ │ │ │ │ │ │ │
│ │ • Per minute │ │ • Per GB │ │ • Per GB │ │
│ │ • VM size │ │ • Operations │ │ • Bandwidth │ │
│ │ • OS license │ │ • Redundancy │ │ • Load balance │ │
│ └────────────────┘ └────────────────┘ └────────────────┘ │
│ │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ Database │ │ Integrations │ │ Support │ │
│ │ │ │ │ │ │ │
│ │ • DTUs/vCores │ │ • Messages │ │ • Basic (free) │ │
│ │ • Storage │ │ • Operations │ │ • Developer │ │
│ │ • Replicas │ │ • Bandwidth │ │ • Professional │ │
│ └────────────────┘ └────────────────┘ │ • Premier │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Free Services:
| Service | Free Tier |
|---|---|
| Azure Functions | 1M requests/month |
| Azure Blob Storage | 5 GB hot + 5 GB cool |
| Azure Functions | $0.20/million executions (first 1M free) |
| Azure SQL | 250 MB DTU-based |
| Azure Cosmos DB | 1,000 RU/s + 25 GB |
| Azure Logic Apps | 4,000 actions/month |
| Azure Static Web Apps | Custom domain, SSL |
Azure Credits:
- Free Account: $200 credit for 30 days + 12 months free
- Visual Studio subscribers: $50-150/month
- Enterprise: Annual commitments
2. Understanding Your Bill
Bill Components:
┌─────────────────────────────────────────────────────────────────┐
│ AZURE BILL BREAKDOWN │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Invoice Section: │
│ ├── Base Charges (metered usage) │
│ ├── Consumed Quantities │
│ ├── Rate per Unit │
│ ├── Subtotals by Service Category │
│ ├── Adjustments & Credits │
│ └── Total Amount Due │
│ │
│ Common Meters: │
│ ├── Compute hours │
│ ├── Storage GB per month │
│ ├── Data transfer GB │
│ ├── Database transactions │
│ └── API calls │
│ │
└─────────────────────────────────────────────────────────────────┘
Reading Your Bill:
- Portal: Cost Management + Billing → Invoices
- Cost Analysis: Detailed breakdown by service
- Resource Costs: Per-resource spending
# List invoices
az billing invoice list -o table
# Download invoice
az billing invoice download \
--invoice-name "F20240101" \
--download-directory ./
# Get current costs
az costmanagement query \
--from-time 2024-01-01 \
--to-time 2024-01-31 \
--granularity Daily
Cost Breakdown by Service:
| Service Category | Typical Cost Drivers |
|---|---|
| Compute | VM hours, cores, memory |
| Storage | GB stored, operations |
| Networking | Data transfer, public IPs |
| Databases | DTUs, vCores, storage |
| Integration | Message operations |
3. Cost Management Tools
Azure Cost Management:
┌─────────────────────────────────────────────────────────────────┐
│ COST MANAGEMENT DASHBOARD │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Cost Analysis │
│ ├── Current spend │
│ ├── Forecasted spend │
│ ├── By resource group │
│ ├── By service │
│ └── By tag │
│ │
│ Budgets │
│ ├── Monthly budgets │
│ ├── Alert thresholds (50%, 75%, 90%) │
│ └── Email notifications │
│ │
│ Recommendations │
│ ├── Right-size recommendations │
│ ├── Reserved capacity suggestions │
│ └── Delete idle resources │
│ │
└─────────────────────────────────────────────────────────────────┘
Using Cost Analysis:
- Portal: Cost Management + Billing → Cost Analysis
- Filter by: Resource group, service, tag, location
- Group by: Service, resource, tag
- Time range: Daily, weekly, monthly
Cost Management API:
# Query costs via CLI
az costmanagement query \
--type ActualCost \
--timeframe MonthToDate \
--dataset-grouping Name=Service,Type=Dimension
# Export costs to storage
az costmanagement export create \
--name MonthlyExport \
--type ActualCost \
--timeframe MonthToDate \
--storage-account mystorage \
--storage-container costs \
--recurrence Monthly
4. Azure Calculators
Pricing Calculator:
URL: https://azure.microsoft.com/pricing/calculator/
Common Calculations:
VM Cost Estimate:
┌─────────────────────────────────────────────────────────────────┐
│ VM PRICING ESTIMATE │
├─────────────────────────────────────────────────────────────────┤
│ Configuration: │
│ ├── Size: D2s_v3 (2 vCPU, 8 GB RAM) │
│ ├── OS: Windows (license included) │
│ ├── Region: East US │
│ ├── Hours: 730/month (full month) │
│ └── Quantity: 3 │
│ │
│ Estimated Cost: │
│ ├── Compute: $138.57/month × 3 = $415.71 │
│ ├── Storage: $12.50 (P10 OS disk) │
│ └── Total: ~$428/month │
└─────────────────────────────────────────────────────────────────┘
Blob Storage Estimate:
┌─────────────────────────────────────────────────────────────────┐
│ STORAGE PRICING ESTIMATE │
├─────────────────────────────────────────────────────────────────┤
│ Configuration: │
│ ├── Type: Block Blob (Hot) │
│ ├── Storage: 1 TB (1,000 GB) │
│ ├── Redundancy: LRS │
│ ├── Operations: 100,000/month │
│ │
│ Estimated Cost: │
│ ├── Storage: 1,000 GB × $0.018 = $18/month │
│ ├── Write ops: 100,000 × $0.00005 = $5/month │
│ ├── Read ops: 100,000 × $0.000004 = $0.40/month │
│ └── Total: ~$23.40/month │
└─────────────────────────────────────────────────────────────────┘
TCO Calculator:
Use for comparing on-premises vs Azure:
- URL: https://azure.microsoft.com/pricing/tco/calculator/
- Input current infrastructure costs
- Get Azure migration savings estimate
5. Cost Optimization Strategies
Right-Sizing:
┌─────────────────────────────────────────────────────────────────┐
│ RIGHT-SIZING PROCESS │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Step 1: Identify underutilized resources │
│ ├── CPU < 10% consistently │
│ ├── Memory < 25% consistently │
│ └── Network traffic minimal │
│ │
│ Step 2: Analyze patterns │
│ ├── Peak usage times │
│ ├── Off-peak usage │
│ └── Growth projections │
│ │
│ Step 3: Resize recommendations │
│ ├── Smaller VM size │
│ ├── Scale down during off-hours │
│ └── Use burstable VMs │
│ │
│ Step 4: Implement changes │
│ ├── Test in dev environment │
│ ├── Monitor performance │
│ └── Adjust if needed │
│ │
└─────────────────────────────────────────────────────────────────┘
Autoscaling:
{
"type": "Microsoft.Insights/autoscaleSettings",
"name": "VMSSAutoscale",
"properties": {
"enabled": true,
"profiles": [
{
"name": "DefaultProfile",
"capacity": {
"minimum": "2",
"maximum": "10",
"default": "2"
},
"rules": [
{
"metricTrigger": {
"metricName": "Percentage CPU",
"operator": "LessThan",
"threshold": 30
},
"scaleAction": {
"direction": "Decrease",
"type": "ChangeCount",
"value": "1",
"cooldown": "PT10M"
}
},
{
"metricTrigger": {
"metricName": "Percentage CPU",
"operator": "GreaterThan",
"threshold": 80
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": "1",
"cooldown": "PT5M"
}
}
]
}
]
}
}
Deallocate Idle Resources:
# List VMs by power state
az vm list --query "[].{name:name, powerState:powerState}" -o table
# Stop (deallocate) idle VMs
az vm stop --resource-group myRG --name myVM
# Auto-shutdown for dev VMs
az vm update \
--resource-group myRG \
--name myVM \
--set autoShutdown Time="18:00"
6. Reserved Instances & Savings Plans
Azure Reservations:
Pre-pay for Azure resources to save up to 72% compared to pay-as-you-go.
┌────────────────────────────────────────────────────────────────────┐
│ RESERVATION SAVINGS │
├────────────────────────┬──────────────────┬────────────────────────┤
│ Resource │ Pay-as-You-Go │ 3-Year Reserved │
├────────────────────────┼──────────────────┼────────────────────────┤
│ D2s_v3 VM (Linux) │ $82.73/month │ $58.36/month (-30%) │
├────────────────────────┼──────────────────┼────────────────────────┤
│ S30 Disk (1 TB) │ $102.20/month │ $73.58/month (-28%) │
├────────────────────────┼──────────────────┼────────────────────────┤
│ Blob Storage (LRS) │ $0.018/GB │ $0.013/GB (-28%) │
└────────────────────────┴──────────────────┴────────────────────────┘
Savings Plans:
Compute Savings Plans - More flexible than reserved instances:
- Work across different VM series
- Can switch sizes freely
- Region-agnostic in some cases
┌──────────────────────────────────────────────────────────────────┐
│ SAVINGS PLAN OPTIONS │
├──────────────────────────────────────────────────────────────────┤
│ Type │ Savings │ Flexibility │
├──────────────────────────┼────────────┼──────────────────────────┤
│ 1-year Reserved │ Up to 40% │ Fixed to one region │
├──────────────────────────┼────────────┼──────────────────────────┤
│ 3-year Reserved │ Up to 72% │ Fixed to one region │
├──────────────────────────┼────────────┼──────────────────────────┤
│ 1-year Savings Plan │ Up to 30% │ Flexible across services│
├──────────────────────────┼────────────┼──────────────────────────┤
│ 3-year Savings Plan │ Up to 60% │ Flexible across services│
└──────────────────────────┴────────────┴──────────────────────────┘
Purchasing Reservations:
# View available reservations
az reservation list
# Calculate reservation savings
az reservation catalog list \
--subscription <sub-id> \
--location eastus
# Purchase reservation
az reservation create \
--reserved-resource-name myVM \
--scope Reservation \
--sku D2s_v3 \
--reserved-resources-count 3 \
--term 1Year
# View reservation coverage
az reservation list --query "[].{id:orderId, used:quantity]"
Azure Hybrid Benefit:
- Use existing Windows Server licenses
- Up to 40-45% savings on Windows VMs
- Also works for SQL Server
# Check if benefit is available
az vm get-instance-view \
--resource-group myRG \
--name myVM \
--query "licenseType"
# Apply benefit
az vm update \
--resource-group myRG \
--name myVM \
--license-type Windows_Server
7. Budgets & Alerts
Creating Budgets:
# Create budget for resource group
az consumption budget create \
--budget-name "RG-Monthly-Budget" \
--resource-group myResourceGroup \
--amount 1000 \
--time-grain Monthly \
--start-date 2024-01-01 \
--thresholds 0.5,0.75,0.9
# Create budget for subscription
az consumption budget create \
--budget-name "Subscription-Budget" \
--subscription <sub-id> \
--amount 10000 \
--time-grain Monthly \
--start-date 2024-01-01
# List budgets
az consumption budget list -o table
# Delete budget
az consumption budget delete \
--budget-name "MyBudget" \
--resource-group myResourceGroup
Budget Thresholds:
┌─────────────────────────────────────────────────────────────────┐
│ BUDGET ALERTS │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Threshold: 50% ──── Alert: Budget 50% consumed │
│ Action: Review spending │
│ │
│ Threshold: 75% ──── Alert: Budget 75% consumed │
│ Action: Investigate unusual activity │
│ │
│ Threshold: 90% ──── Alert: Budget 90% consumed │
│ Action: Prepare to take action │
│ │
│ Threshold: 100% ──── Alert: Budget exceeded │
│ Action: Immediate review needed │
│ │
└─────────────────────────────────────────────────────────────────┘
Cost Alerts Configuration:
- Go to Cost Management + Billing → Budgets
- Click + Add
- Configure:
- Name
- Amount
- Reset period (Monthly, Quarterly, Annually)
- Alert recipients (email addresses)
- Alert thresholds (% of budget)
- Create
8. Best Practices
Cost Management Checklist:
┌─────────────────────────────────────────────────────────────────┐
│ COST OPTIMIZATION CHECKLIST │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Planning & Design │
│ ├── Use Azure Calculator for estimates │
│ ├── Implement tagging strategy │
│ ├── Right-size from start │
│ └── Plan for auto-shutdown │
│ │
│ Monitoring & Alerting │
│ ├── Set up budgets for all scopes │
│ ├── Configure 80% alert threshold │
│ ├── Review cost analysis weekly │
│ └── Track cost trends │
│ │
│ Optimization │
│ ├── Enable Azure Advisor recommendations │
│ ├── Delete unused resources │
│ ├── Use reserved capacity for stable workloads │
│ ├── Enable autoscaling │
│ └── Use zone-redundant resources only if needed │
│ │
│ Governance │
│ ├── Require tags for all resources │
│ ├── Deny expensive SKUs (where possible) │
│ ├── Use Azure Policy for cost controls │
│ └── Regular cost reviews with teams │
│ │
└─────────────────────────────────────────────────────────────────┘
Common Cost Mistakes:
| Mistake | Impact | Solution |
|---|---|---|
| Leaving VMs running 24/7 | Wasted spend | Auto-shutdown, smaller size |
| Overprovisioned storage | Unnecessary cost | Right-size, lifecycle policies |
| No redundancy planning | Unexpected costs | Plan for GRS only if needed |
| Ignoring reserved instances | 40-70% overspend | Buy 3-year reserved for stable |
| No budget alerts | Surprise bills | Set up 80% threshold alerts |
Monthly Cost Review Process:
- Review spend - Total vs. budget
- Identify outliers - Unexpected high-cost resources
- Check recommendations - Azure Advisor suggestions
- Optimize - Apply right-sizing, delete unused
- Plan - Adjust budgets if needed
Quick Reference - Cost Commands:
┌─────────────────────────────────────────────────────────────────┐
│ COST MANAGEMENT COMMANDS │
├─────────────────────────────────────────────────────────────────┤
│ List costs: az costmanagement query │
│ List budgets: az consumption budget list │
│ Create budget: az consumption budget create │
│ List resources: az resource list --query "[].name" │
│ Get VM status: az vm list --query "[].{name:name,state:powerState}"
│ Stop VM: az vm stop -g <rg> -n <name> │
│ Delete resource: az resource delete -g <rg> -n <name> │
└─────────────────────────────────────────────────────────────────┘
Hands-On Lab:
Exercise 1: Calculate VM Costs
- Use Azure Pricing Calculator
- Estimate 5 VMs with different sizes
- Add storage and networking costs
Exercise 2: Set Up Budget Alerts
- Create a $500/month budget
- Set thresholds at 50%, 75%, 90%
- Add your email as recipient
Exercise 3: Optimize Resources
- Find underutilized VMs (>50% idle)
- Right-size or stop them
- Document savings
Exercise 4: Purchase Reserved Instance
- Identify stable workload (running 24/7)
- Buy 3-year reservation
- Verify savings in cost analysis
Next Steps:
- Explore Azure Cost Management REST API
- Learn about FinOps practices
- Implement cost chargeback to teams
Azure Integration Hub - Learning Roadmap Level: Beginner | Topic: Azure Pricing & Cost Management