Azure Cheatsheet

Cost and Free Tier

Use this Azure reference while you build software engineering projects, review code, or refresh the syntax you reach for most.

Free Account Tiers

Azure has two permanent free structures:

TypeDurationWhat's free
Always FreePermanentA fixed set of services at limited scale
12-Month FreeFirst year onlyKey services with generous limits
$200 creditFirst 30 daysSpend on anything

Sign up: azure.microsoft.com/free

Always Free (no expiry)

ServiceFree limit
Azure Functions1M requests + 400,000 GB-s/month
Cosmos DB1,000 RU/s + 25 GB storage
App Service10 apps on F1 (shared, 60 min CPU/day)
Azure DevOps5 users, unlimited private repos
GitHub Actions (Azure-hosted)2,000 min/month (public repos: unlimited)
Azure Kubernetes ServiceNo charge for cluster management (pay for VMs)
Container Registry— (Basic SKU ~$5/mo — not free)
Azure SQL (Serverless)100,000 vCore-seconds + 32 GB (12-mo only)
Bandwidth15 GB/month outbound (first 5 GB free globally)
Azure Active Directory (Entra ID)Free tier — up to 50,000 objects
Key Vault10,000 operations/month
Monitor (Metrics)Built-in platform metrics free forever
Monitor (Logs)5 GB Log Analytics ingestion/month

12-Month Free Highlights

ServiceFree limitNotes
Linux/Windows VMs750 hrs/month × 2 (B1s)One Linux + one Windows
Blob Storage5 GB LRS + 20k reads + 10k writesStandard tier
Azure SQL Database100,000 vCore-seconds + 32 GBServerless Gen5
Cognitive Services5,000 transactions/monthFace, Vision, Language
Bandwidth15 GB outboundFirst 15 GB free each month

Key Pricing Concepts

Compute

VMs are billed per second of uptime (when allocated).
Stop + Deallocate → no compute charge (disk still billed).
Stop only (OS shutdown) → still billed!

Savings options:
  Reserved Instances (1yr / 3yr)  → up to 72% off pay-as-you-go
  Azure Hybrid Benefit             → bring existing Windows Server / SQL licenses
  Spot VMs                         → up to 90% off, can be evicted at any time
  Dev/Test pricing                 → discounted rates for non-prod (requires MSDN)

Storage

TierUse$/GB/month (LRS, East US)
HotFrequent access~$0.018
CoolInfrequent (≥30 days)~$0.01
ColdRarely accessed (≥90 days)~$0.0045
ArchiveOffline (≥180 days, 15h rehydrate)~$0.00099

Networking

Inbound data transfer:  FREE
Outbound (internet):    First 100 GB/month FREE, then ~$0.087/GB (Zone 1)
VNet-to-VNet peering:   ~$0.01/GB
ExpressRoute:           Port fee + data (varies by circuit)

Database

Azure SQL (vCore General Purpose, East US):
  GP_Gen5_2:  ~$0.3685/vCore/hour (~$536/month per 2 vCores)
  Serverless: billed only when DB is active (auto-pause available)
  Reserved 1yr: ~37% discount; 3yr: ~55% discount

Cosmos DB:
  Provisioned: $0.008/hour per 100 RU/s + $0.25/GB
  Serverless:  $0.25 per 1M RUs + $0.25/GB

Cost Management Tools

# Show current month's cost (requires Billing Reader role)
az consumption usage list \
  --start-date 2024-06-01 --end-date 2024-06-30 \
  -o table

# Show cost by resource group (Cost Management extension)
az extension add --name costmanagement

az costmanagement query \
  --type Usage \
  --timeframe MonthToDate \
  --dataset-granularity Daily \
  --dataset-aggregation '{"totalCost":{"name":"Cost","function":"Sum"}}' \
  --dataset-grouping '{"name":"ResourceGroupName","type":"Dimension"}' \
  -o table

# Create a budget with email alert
az consumption budget create \
  --budget-name myBudget \
  --amount 100 \
  --time-grain Monthly \
  --category Cost \
  --notifications '[{"enabled":true,"operator":"GreaterThan","threshold":80,"contactEmails":["admin@example.com"],"thresholdType":"Actual"}]'

# List budgets
az consumption budget list -o table

Cost Reduction Checklist

- Deallocate VMs when not in use (az vm deallocate). - Use Spot VMs for fault-tolerant batch jobs. - Purchase Reserved Instances for stable 1–3yr workloads (>72% savings). - Enable Azure Hybrid Benefit if you have Windows Server / SQL Server licenses. - Set auto-pause on serverless SQL databases (--auto-pause-delay 60). - Lifecycle management on Blob Storage — move cold data to Cool → Archive. - Right-size VMs with Azure Advisor recommendations: ``bash az advisor recommendation list --category Cost -o table `` - Use Azure Dev/Test subscriptions for non-production workloads. - Enable Budget alerts so you know before you overspend. - Delete unused Public IPs, unattached disks, and empty resource groups.

Azure Pricing Calculator

Use the web calculator for estimates before deploying: azure.microsoft.com/pricing/calculator

# Compare reservation savings for a VM size
az vm list-skus --location eastus --size Standard_D4s_v5 \
  --query "[].{Name:name,Tier:tier,Size:size}" -o table

Cost Allocation: Tags Strategy

# Enforce tagging via policy (deny untagged resources)
az policy assignment create \
  --name require-env-tag \
  --scope /subscriptions/<sub>/resourceGroups/myRG \
  --policy "871b6d14-10aa-478d-b590-94f262ecfa99"   # "Require a tag on resources"

# Recommended tags
az group update --name myRG \
  --tags env=prod team=platform cost-center=eng12 owner=alice

# Group costs by tag in Cost Management portal:
# Cost Management → Cost Analysis → Group by → Tag → "env"