Compute: VMs & Scale Sets
Deploy and scale virtual machines, and choose between VMs, scale sets, and containers.
Virtual Machines are Azure’s IaaS compute. You choose a size (VM series for general/compute/memory/GPU workloads), an image (OS), and disks (managed, Premium SSD for production). For availability, spread VMs across availability zones or an availability set.
To scale, Virtual Machine Scale Sets (VMSS) run identical VMs behind a load balancer and autoscale on metrics like CPU. For containerized or serverless work you’d instead pick AKS or Container Instances — but VMs remain the go-to for lift-and-shift and full OS control.
az vm create -g rg-app -n vm-web \
--image Ubuntu2204 --size Standard_B2s \
--admin-username azureuser --generate-ssh-keys --zone 1
# A scale set that autoscales on CPU
az vmss create -g rg-app -n vmss-web --image Ubuntu2204 \
--instance-count 2 --vm-sku Standard_B2s
az monitor autoscale create -g rg-app --resource vmss-web \
--resource-type Microsoft.Compute/virtualMachineScaleSets \
--min-count 2 --max-count 10 --count 2 - Choose a VM series for a memory-heavy database vs a CPU-bound batch job.
- Explain how a scale set differs from a single VM.
- Describe an autoscale rule: add an instance when CPU > 70% for 5 minutes.
- Compare availability zones vs availability sets for resilience.
Cheat Sheet▾
| Item | Detail |
|---|---|
| VM size series | B (burst), D (general), E (memory), F (compute) |
| Disks | Standard/Premium SSD, managed |
| Availability set | Fault/update domains (one DC) |
| Availability zones | Separate datacenters |
| VMSS | Identical VMs + autoscale |
| Autoscale metric | CPU %, queue length, schedule |
Common Interview Questions▾
What is a Virtual Machine Scale Set?
A group of identical, load-balanced VMs that can automatically scale in/out based on metrics or a schedule — used for elastic, stateless workloads.
Availability set vs availability zone — what's the difference?
An availability set distributes VMs across fault/update domains within one datacenter; availability zones place them in physically separate datacenters, protecting against a full-datacenter outage.