Virtual machines: sizes, disks and management
Pick a VM size by decoding its name, choose the right disks and encryption, and resize, redeploy or move VMs without surprises.
In this lesson you'll learn
- How to read any VM size name
- Managed disk types, caching and the temporary disk
- Encryption at host, Azure Disk Encryption and customer-managed keys
- Resizing, redeploying, moving and extending VMs
1. Decode a VM size
New to VMs? Start here
A virtual machine is a computer running on Microsoft's hardware. You choose its size (CPU and memory), its image (Windows or Linux), its disks and its network. You pay per second while it runs, plus storage for its disks all the time.
Size names look cryptic but follow a pattern. Type one in, or pick an example.
Try it in the app. This lesson has an interactive VM size picker here. Open the lesson in the exam app
| Family | Optimised for | Example use |
|---|---|---|
| B | Burstable, cheap | Dev boxes, small sites |
| D | General purpose | Web and app servers |
| E | Memory | Databases, caches |
| F | Compute | Batch processing, gaming servers |
| L | Storage throughput | Big data, NoSQL |
| M | Very large memory | SAP HANA |
| N | GPU | AI, rendering |
2. Disks
| Disk type | Best for | Notes |
|---|---|---|
| Standard HDD | Backups, rarely used data | Cheapest |
| Standard SSD | Light web servers, dev | Consistent but modest speed |
| Premium SSD | Production workloads | Supports ZRS for zone resilience |
| Premium SSD v2 | Databases needing tuned IOPS | Data disks only |
| Ultra Disk | The most demanding I/O | Data disks only |
Host caching: use ReadOnly for data disks that are read heavily, None for write-heavy log disks, and ReadWrite only for the OS disk.
3. Encryption options
| Option | What it does |
|---|---|
| Server-side encryption | On by default. Disks are encrypted at rest in storage with platform keys or your own keys (via a disk encryption set). |
| Encryption at host | Also encrypts the temporary disk and disk caches on the host. Recommended for new VMs. |
| Azure Disk Encryption | BitLocker or DM-Crypt inside the guest OS, keys in Key Vault. Data stays encrypted even if the VHD is downloaded. |
| Confidential disk encryption | For confidential VMs, tied to the VM's hardware security. |
4. Managing VMs
| Task | Downtime? | What to know |
|---|---|---|
| Resize | Restart | If the new size is not on the current hardware cluster, deallocate first. In an availability set, all VMs may need deallocating. |
| Add a data disk | No | Data disks attach and detach while running. |
| Install an extension | No | Custom Script Extension runs scripts, DSC applies configuration. |
| Redeploy | Yes | Moves the VM to a new host. Temporary disk data is lost. |
| Move to another resource group or subscription | No | Region stays the same. Move dependent resources together. |
| Move to another region | Yes | Use Azure Resource Mover or Site Recovery. |
| Change VNet, availability set or zone | Yes | Delete the VM keeping its disks, then recreate it. |
Example
SS Kaiser's reporting VM runs out of memory every month-end. Its size is D4s_v5 (16 GB). The admin resizes it to E4s_v5, the memory-optimised family with 32 GB, during the Sunday maintenance window. The restart takes two minutes and month-end runs smoothly.
Exam focus
Regional vCPU quotas count all VMs, including stopped (deallocated) ones. Add up the vCPUs of every VM before deciding if a new one fits.
5. Creating a VM: the choices that matter
Whether you use the portal, the Azure CLI or PowerShell, creating a VM means making the same decisions. Most can't be changed later without recreating the VM, so they're popular exam topics.
| Choice | Change later? | What to know |
|---|---|---|
| Region | No (move or recreate) | Decides which sizes, zones and services are available, and the price. |
| Availability options | No | None, availability zone, availability set or scale set. Set at creation only. |
| Security type | Limited | Trusted launch (secure boot and vTPM) is the default for Generation 2 images. |
| Image | No | Marketplace, Azure Compute Gallery or a custom image. Generalised images give each VM a new identity. |
| Size | Yes (restart) | Must be available in the region and zone. Check quota first. |
| Administrator account | Reset only | Username and password, or an SSH key for Linux. Never stored in an exported template. |
| Inbound ports | Yes | The portal creates an NSG rule. Prefer none, and connect through Bastion. |
| OS disk type | Yes (VM stopped) | Standard HDD, Standard SSD or Premium SSD. Premium needs a size that supports it. |
| Virtual network and subnet | Subnet only | The VNet can't change after creation. Choose carefully. |
| Public IP | Yes | Standard SKU, static. Leave it off for internal servers. |
The same VM from the Azure CLI, using a single command:
az vm create --resource-group RG1 --name VM1 --image Ubuntu2204 --size Standard_D2s_v5 --zone 1 --admin-username azureuser --generate-ssh-keys --public-ip-address ""
PowerShell uses New-AzVM with the same choices as parameters.
Exam focus
If a question asks what you must set when deploying a VM from a saved template, the answer is usually the resource group and the administrator credentials. Exported templates don't keep them.
Exam traps to remember
- Drive D on Windows VMs is usually the temporary disk.
- Stopped from inside the OS still costs compute. Stopped (deallocated) from Azure does not.
- Upload on-premises disks with Add-AzVhd. Azure needs fixed-size VHD, not VHDX.
- Ultra Disk and Premium SSD v2 cannot be OS disks.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-104 Azure Administrator app.
Practise in the app