Virtual machines: sizes, disks and management

AZ-104 Azure AdministratorComputeAbout 25 minutesBy Cloud Hands On

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

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

FamilyOptimised forExample use
BBurstable, cheapDev boxes, small sites
DGeneral purposeWeb and app servers
EMemoryDatabases, caches
FComputeBatch processing, gaming servers
LStorage throughputBig data, NoSQL
MVery large memorySAP HANA
NGPUAI, rendering

2. Disks

A VM has a persistent OS disk, persistent data disks and a temporary disk on the host that is wiped on redeploy VM OS disk (C:)Persistent, managed Data disksPersistent, hot-attach Temporary disk (D:)On the host, wiped
Never keep anything important on the temporary disk. It is lost on redeploy, on deallocation and when the host fails.
Disk typeBest forNotes
Standard HDDBackups, rarely used dataCheapest
Standard SSDLight web servers, devConsistent but modest speed
Premium SSDProduction workloadsSupports ZRS for zone resilience
Premium SSD v2Databases needing tuned IOPSData disks only
Ultra DiskThe most demanding I/OData 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

OptionWhat it does
Server-side encryptionOn by default. Disks are encrypted at rest in storage with platform keys or your own keys (via a disk encryption set).
Encryption at hostAlso encrypts the temporary disk and disk caches on the host. Recommended for new VMs.
Azure Disk EncryptionBitLocker or DM-Crypt inside the guest OS, keys in Key Vault. Data stays encrypted even if the VHD is downloaded.
Confidential disk encryptionFor confidential VMs, tied to the VM's hardware security.

4. Managing VMs

TaskDowntime?What to know
ResizeRestartIf the new size is not on the current hardware cluster, deallocate first. In an availability set, all VMs may need deallocating.
Add a data diskNoData disks attach and detach while running.
Install an extensionNoCustom Script Extension runs scripts, DSC applies configuration.
RedeployYesMoves the VM to a new host. Temporary disk data is lost.
Move to another resource group or subscriptionNoRegion stays the same. Move dependent resources together.
Move to another regionYesUse Azure Resource Mover or Site Recovery.
Change VNet, availability set or zoneYesDelete 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.

ChoiceChange later?What to know
RegionNo (move or recreate)Decides which sizes, zones and services are available, and the price.
Availability optionsNoNone, availability zone, availability set or scale set. Set at creation only.
Security typeLimitedTrusted launch (secure boot and vTPM) is the default for Generation 2 images.
ImageNoMarketplace, Azure Compute Gallery or a custom image. Generalised images give each VM a new identity.
SizeYes (restart)Must be available in the region and zone. Check quota first.
Administrator accountReset onlyUsername and password, or an SSH key for Linux. Never stored in an exported template.
Inbound portsYesThe portal creates an NSG rule. Prefer none, and connect through Bastion.
OS disk typeYes (VM stopped)Standard HDD, Standard SSD or Premium SSD. Premium needs a size that supports it.
Virtual network and subnetSubnet onlyThe VNet can't change after creation. Choose carefully.
Public IPYesStandard 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

Keep going