TL;DR
Master Azure Virtual Machines with this comprehensive guide covering VM types, networking, storage options, scaling, and best practices for production workloads.
Azure Virtual Machines: Complete Implementation Guide
Executive Summary
Azure Virtual Machines are the lift-and-shift foundation of Azure: full control of the operating system and everything on it, in exchange for owning patching, availability design, and scaling yourself. This guide covers the decisions that shape a VM estate — series and sizing, managed disks, networking and access control, availability sets versus zones versus scale sets, backup and patching. After reading it you will be able to provision VMs that are sized from evidence rather than habit, protected by backup and just-in-time access, and placed so that a single hardware failure or maintenance event does not become an outage.
Why This Matters
VMs fail in predictable, preventable ways. A single VM with no availability design goes down when its host is serviced. An oversized instance burns budget every hour it runs; an undersized one pages at peak load. A VM with a public IP and password authentication enabled is found by scanners within hours of creation. And the estate that nobody patched or backed up discovers both facts during the same incident.
Core Concepts
Series and Sizing
Azure VM names encode the family and size. The families that matter:
Size from measurement, not from the size of the on-premises box being replaced — source systems are routinely oversized. List what a region actually offers before committing to a size in a template:
# List available VM sizes in a region az vm list-sizes --location eastus # Get VM size details az vm list-sizes --location eastus --query "[?contains(name, 'Standard_D2s_v3')]"
Sizes are not available in every region or zone, and quota is per family per region — verify both before a deployment depends on them.
Creating a VM
# Create a resource group
az group create --name myResourceGroup --location eastus
# Create a VM
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys \
--size Standard_D2s_v3The CLI creates supporting resources (VNet, public IP, NSG) when they are not specified — convenient for a first VM, and exactly what you should not rely on in production, where networking is designed explicitly and most VMs should have no public IP at all.
Declared as infrastructure, the storage and network profile of a VM looks like this:
{
"vmSize": "Standard_D2s_v3",
"storageProfile": {
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
},
"dataDisks": [
{
"diskSizeGB": 100,
"lun": 0,
"createOption": "Empty"
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', 'myNIC')]"
}
]
}
}Networking
VMs live in subnets, and subnet design is security design: group VMs by trust level, and filter with network security groups. Administrative access should never be a standing open rule — use Azure Bastion or just-in-time access instead.
# Create a virtual network
az network vnet create \
--resource-group myResourceGroup \
--name myVNet \
--address-prefix 10.0.0.0/16 \
--subnet-name mySubnet \
--subnet-prefix 10.0.0.0/24
# Create a network security group
az network nsg create \
--resource-group myResourceGroup \
--name myNSG
# Add security rules
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name myNSG \
--name allow-ssh \
--protocol tcp \
--priority 1000 \
--destination-port-range 22 \
--access allowEnable accelerated networking on sizes that support it for latency- and throughput-sensitive workloads; it bypasses the host's virtual switch path and is free, but must be set when the NIC is created.
Storage: Managed Disks
Managed disks are the storage unit: you pick a type and size, Azure handles the rest. The tiers trade performance for cost — Ultra Disk for the most demanding I/O, Premium SSD for production workloads, Standard SSD for lighter duties, Standard HDD for bulk and backup. Disk performance is capped both by the disk tier and by the VM size, so a fast disk on a small VM wastes money. Caching settings matter too: for data disks hosting databases, caching can hurt more than help — follow the workload vendor's guidance rather than defaults.
# Add a data disk
az vm disk attach \
--resource-group myResourceGroup \
--vm-name myVM \
--name myDataDisk \
--size-gb 100 \
--sku Premium_LRS \
--newEnable Azure Disk Encryption or rely on the platform's encryption at rest, and use customer-managed keys from Key Vault when your compliance regime requires controlling the key lifecycle.
Availability: Sets, Zones, and Scale Sets
A single VM has no availability protection against host failure or maintenance. Three mechanisms address different problems:
Availability sets distribute VMs across fault domains (racks) and update domains (maintenance batches) within a datacenter. They are the older mechanism, scoped to one region and one datacenter generation.
# Create an availability set
az vm availability-set create \
--resource-group myResourceGroup \
--name myAvailabilitySet \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5Availability zones are physically separate datacenters within a region and are the preferred placement for new production workloads — a zone failure should not touch a well-placed pair of VMs.
Virtual Machine Scale Sets manage a pool of identical VMs behind a load balancer, with autoscaling rules and rolling upgrades — the right shape for stateless tiers that grow and shrink:
# Create a scale set
az vmss create \
--resource-group myResourceGroup \
--name myScaleSet \
--image Ubuntu2204 \
--upgrade-policy-mode automatic \
--admin-username azureuser \
--generate-ssh-keys \
--instance-count 3Monitoring and Patching
Boot diagnostics captures the serial console and screenshots — the evidence you need when a VM will not start:
# Enable boot diagnostics
az vm boot-diagnostics enable \
--name myVM \
--resource-group myResourceGroup
# Configure metrics collection
az monitor metrics alert create \
--name cpu-alert \
--resource-group myResourceGroup \
--scopes /subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM \
--condition "avg Percentage CPU > 80" \
--window-size 5m \
--evaluation-frequency 1mPatching is the operational obligation VMs carry that PaaS does not. Azure Update Manager applies OS updates on a schedule with maintenance windows and reboot control; pair it with a policy that reports compliance so unpatched machines are visible rather than discovered. Enable automatic guest patching only where unplanned reboots are acceptable.
Backup and Disaster Recovery
Azure Backup protects VMs at the image level with application-consistent snapshots and point-in-time restore to the vault's retention:
# Create a Recovery Services vault
az backup vault create \
--resource-group myResourceGroup \
--name myVault \
--location eastus
# Enable backup
az backup protection enable-for-vm \
--resource-group myResourceGroup \
--vault-name myVault \
--vm myVM \
--policy-name DefaultPolicyBackup is not disaster recovery: restoring into the same region does nothing for a regional failure. Azure Site Recovery replicates VMs to a secondary region for that case. Decide which workloads need which, and test restores — a backup that has never been restored is a hypothesis.
Cost Controls
The levers that actually move a VM bill: right-sizing from utilisation data, reserved instances or savings plans for steady workloads, spot VMs for interruptible work, and shutting down what is not used.
# Convert to spot instance
az vm update \
--resource-group myResourceGroup \
--name myVM \
--priority Spot \
--max-price -1
# Enable auto-shutdown
az vm auto-shutdown \
--resource-group myResourceGroup \
--name myVM \
--time 1730Note that converting a running VM to spot changes its eviction contract — only do it to workloads designed to be interrupted. Tag everything with owner and environment so cost reports assign spend to a team, not a mystery.
Decision Framework
| Situation | Recommendation |
|---|---|
| Lift-and-shift of an existing server workload | Azure VMs, sized from source utilisation data |
| Stateless web or API tier with variable load | VM Scale Sets behind a load balancer, or evaluate App Service/Container Apps first |
| Production workload needing resilience within a region | Availability zones; availability set only where zones are unavailable |
| Regional failure must be survivable | Site Recovery replication to a secondary region, with a tested failover runbook |
| Interruptible batch or CI work | Spot VMs with eviction handling in the workload |
| Steady 24x7 workload | Reserved capacity or a savings plan once the size is proven stable |
Implementation Checklist
Trade-offs
VMs maximise control and compatibility — any legacy agent, kernel requirement, or odd licence term can usually be accommodated — and in exchange you own the entire operational stack: patching, hardening, availability, scaling, backup. Per-second billing makes VMs look cheap at creation and expensive at estate scale, where idle and oversized machines dominate. Scale sets recover some elasticity, but stateful workloads on VMs remain pets that must be fed individually, however good the automation around them.
When Not to Use
Conclusion
Azure VMs reward the teams that treat them as managed assets rather than rented servers: sized from evidence, placed across zones, patched and backed up on a schedule, and reached through Bastion or just-in-time access instead of open ports. Apply those defaults and a VM estate is dependable. Skip them, and the platform's flexibility becomes a list of ways to be unavailable, unpatched, and over budget at the same time.
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.