Azure Virtual Machines: Sizes, Images, Disks, Networking, Extensions, Custom Script and Secure Access
What Is an Azure VM?
A virtual machine (VM) is an on-demand server in Azure. It is IaaS: you pick the size and operating system and you manage updates, software and security inside the VM.
VM Size Families
| Family (letter) | Examples | Best for |
|---|---|---|
| General purpose | B (burstable), D, Dads, DC | Web servers, small databases, dev/test |
| Compute optimized | F | Batch, gaming, web with high CPU |
| Memory optimized | E, M | Databases, in-memory analytics, SAP |
| Storage optimized | L | Big data, NoSQL with high disk throughput |
| GPU | N | AI training, graphics |
| High performance compute | H | Simulation, modeling |
- A name like
Standard_D4s_v5means family D, 4 vCPUs, premium storage capable (s), generation v5 - B-series is cheap and bursts when it has credits. Good for light, spiky loads
- Arm-based sizes (for example
Dps) can be cheaper if your software supports Arm
bash
az vm list-sizes --location centralindia --query "[?numberOfCores==\`2\`].{name:name, mem:memoryInMb}" -o table
az vm create -g rg-demo -n web01 --image Ubuntu2204 --size Standard_B2s --admin-username azureuser --ssh-key-values ~/.ssh/id_rsa.pub \
--vnet-name vnet-app --subnet web --nsg nsg-web --public-ip-sku Standard --zone 1
Images and Customization
- Marketplace images: Windows Server, Ubuntu, Red Hat, SQL Server images and many vendor appliances
- Custom images and the Azure Compute Gallery share your golden image across regions and subscriptions
- cloud-init (Linux) or Custom Script Extension run setup at first boot
- VM extensions add features: monitoring agent, antimalware, DSC, Custom Script
bash
cat > cloud-init.yaml <<'EOF'
#cloud-config
package_update: true
packages: [nginx]
runcmd:
- echo "Hello from $(hostname)" > /var/www/html/index.nginx-debian.html
EOF
az vm create -g rg-demo -n web02 --image Ubuntu2204 --size Standard_B1s --custom-data cloud-init.yaml --admin-username azureuser --generate-ssh-keys
az vm open-port -g rg-demo -n web02 --port 80
Managed Disks
| Disk type | Use |
|---|---|
| Standard HDD | Backups, infrequent access |
| Standard SSD | Web servers, light workloads |
| Premium SSD / Premium SSD v2 | Production and databases. v2 lets you tune size, IOPS and throughput separately |
| Ultra Disk | Very high IOPS and low latency, such as large databases |
- Each VM has an OS disk, optional data disks and a temporary disk (data is lost on redeploy or move: never keep important data there)
- Managed disks handle storage accounts for you and support zone-redundant (ZRS) options
- Encrypted by default with platform-managed keys. You can use customer-managed keys or encryption at host
- Snapshots and Azure Backup protect disks
bash
az disk create -g rg-demo -n data01 --size-gb 128 --sku Premium_LRS
az vm disk attach -g rg-demo --vm-name web01 --name data01
az vm update -g rg-demo -n web01 --size Standard_D2s_v5 # resize (VM restarts)
az snapshot create -g rg-demo -n snap-web01 --source $(az vm show -g rg-demo -n web01 --query "storageProfile.osDisk.managedDisk.id" -o tsv)
Networking Parts of a VM
- A VM has one or more network interfaces (NICs) in a subnet of a virtual network
- Use private IPs and a load balancer or Bastion instead of exposing every VM with a public IP
- NSGs (network security groups) filter traffic at the subnet or NIC
Secure Access
| Option | How |
|---|---|
| Azure Bastion | Browser or native-client RDP/SSH over TLS from the portal. No public IP and no open 22/3389 on VMs |
| Just-in-Time (JIT) VM access | Defender for Cloud opens management ports only for a limited time on request |
| Entra ID login for VMs | Sign in to Linux and Windows VMs with Entra accounts and RBAC (Virtual Machine Administrator Login) |
| SSH keys (Linux) | Safer than passwords |
| Managed identity | VM gets an identity for Azure resources |
Availability and Cost Options
| Option | Notes |
|---|---|
| Availability zones | Place VMs in different zones. 99.99 percent SLA for two or more zonal VMs |
| Availability sets | Spread across fault and update domains in one datacenter. 99.95 percent SLA |
| Single VM with Premium SSD | 99.9 percent SLA |
| Spot VMs | Cheap, can be evicted |
| Reserved instances / savings plans | Discount for steady use |
| Auto-shutdown | Schedule shutdown for dev VMs |
SLA numbers are summaries. Check the current Azure SLA documents.
Practice
- Create a Linux VM with cloud-init that installs nginx and open it in a browser
- Attach a 128 GB Premium SSD data disk, format and mount it
- Resize the VM and watch it restart
- Connect with Azure Bastion without a public IP
- Delete the resource group
Conclusion
Azure VMs are IaaS servers. Choose a size family for the workload, use managed disks and images, automate setup with cloud-init or extensions, reach VMs through Bastion or JIT and use zones for availability.
Quick Summary: VM; sizes; images; disks; networking; access; availability.

