VM Disks and Encryption at Host
30-second answer
An Azure VM has an OS disk and optional data disks, both managed disks stored in Azure Storage, plus a temporary disk on the host that loses its data when the VM is deallocated or moved. Disk types are Ultra Disk, Premium SSD v2, Premium SSD, Standard SSD and Standard HDD. You can attach data disks while the VM runs and grow disks (never shrink them), but changing a disk's type needs the VM deallocated or the disk detached. Managed disks are always encrypted at rest; encryption at host also encrypts the temp disk and the disk caches on the host. Register the EncryptionAtHost feature once, deallocate the VM, then turn it on.
Simulate it » No Azure account neededExam objective: 3.2.5 Manage virtual machine disks. 3.2.2 Configure encryption at host for Azure virtual machines. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Encryption at host must be <strong>registered once per subscription</strong>. Do it in Cloud Shell (or under <strong>Subscriptions › Preview features</strong>).
👆 Click the glowing item in the portal to continue
Read the steps as text
- Encryption at host must be registered once per subscription. Do it in Cloud Shell (or under Subscriptions › Preview features).
- Open vm-app-01. It's Stopped (deallocated), which encryption at host needs before you can switch it on. Open Settings › Disks.
- The OS disk is listed first. Under Data disks, select + Create and attach a new disk.
- Name it, keep Premium SSD, set 128 GiB and Read-only caching, then Save. Data disks can also be attached while the VM runs.
- Select Additional settings and set Encryption at host to Yes. It encrypts the temp disk and the OS and data disk caches on the host, and the data flows to Storage already encrypted.
- Open the data disk and Size + performance. Switch to Standard SSD and grow it to 256 GiB. Changing the type needs the VM deallocated (or the disk detached), and you can grow a disk but never shrink it.
- Start the VM. CLI for the whole job: az vm deallocate, az vm update --set securityProfile.encryptionAtHost=true, az disk update --sku StandardSSD_LRS --size-gb 256, az vm start.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Disks and encryption at host
OS and data disks are managed disks in Azure Storage, encrypted at rest by default. The temp disk and the disk caches live on the host. Encryption at host encrypts those too, end to end; it needs the feature registered and the VM deallocated.
🤔 What happens if…
Read this tour as text
- A Bicep file becomes resources. A template has four parts: parameters (inputs such as
storageNameandskuName), variables (values worked out once), resources (what gets built) and outputs (values handed back). The CLI compiles Bicep to ARM JSON and Azure Resource Manager validates it, then builds it. - what-if, Incremental and Complete. what-if previews the changes (
+create,~modify,-delete) without touching anything. Incremental mode, the default, adds and updates. Complete mode also deletes whatever in the resource group isn't in the template. - Export and decompile. Export template (portal, or
az group export) writes what exists now as ARM JSON.az bicep decompileturns JSON into Bicep. Both are starting points: names and values are hard-coded and some properties are missing. - A VM, its host and its size. A VM runs on a physical host in a hardware cluster. Its size (Standard_D2s_v5: D family, 2 vCPUs, premium storage, v5) sets CPU, memory, disk count and price. A resize restarts the VM; a size that isn't on the current cluster needs the VM deallocated first.
- Disks and encryption at host. OS and data disks are managed disks in Azure Storage, encrypted at rest by default. The temp disk and the disk caches live on the host. Encryption at host encrypts those too, end to end; it needs the feature registered and the VM deallocated.
- Move to another resource group or subscription. A move keeps the region and the VM keeps running, but every resource ID changes. The VM must travel with its disks and network interface; across subscriptions the virtual network goes too.
- Move to another region. Azure Resource Mover copies resources to another region: add them, validate dependencies, prepare, initiate move, then commit (or discard) and delete the source.
- Availability sets vs zones. An availability set spreads VMs over fault domains (racks with their own power and network) and update domains in one datacenter: 99.95%. Availability zones spread VMs over separate datacenters: 99.99%. A VM uses one or the other, chosen at creation.
- Scale sets grow on a rule. A Virtual Machine Scale Set (Flexible orchestration recommended) runs identical VMs across zones. Autoscale rules add instances when average CPU is high and remove them when it's low, always between the minimum and maximum.
Build Contoso's app server, then do the jobs an admin gets every week: a bigger size, a data disk, encryption at host and a cheaper disk tier. Some of these need the VM deallocated, and the shell will tell you when you forget.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Auditors ask whether the temp disk and disk caches are encrypted.
😊 THE SOLUTION
Turn on encryption at host so data is encrypted from the host to Storage.
- App data on the OS disk✓ A separate data disk
- Temp disk and cache not covered✓ Encryption at host
- Premium disk for cold data✓ Change to Standard SSD
Start with a question
If your house is locked, is the post on your doormat safe?
Your filing cabinet is locked. Great. But the letter you’re working on sits on the desk by the window, and the post waits on the doormat. Locking the cabinet didn’t protect those.
A VM’s managed disks are the locked cabinet: encrypted in Azure Storage by default. The temp disk and the disk cache are the desk and the doormat, on the physical host. Encryption at host locks those too.
Explain it like I’m 10
The technical explanation
The three kinds of disk
| Disk | Where it lives | Survives deallocation? | Use it for |
|---|---|---|---|
| OS disk | Managed disk in Azure Storage | Yes | The operating system |
| Data disk | Managed disk in Azure Storage | Yes | Databases, app files, logs |
| Temporary disk | Local storage on the host | No | Page file, swap, scratch data |
Managed disk types, fastest first: Ultra Disk and Premium SSD v2 (performance set separately from size, no host caching), Premium SSD (production), Standard SSD (light production, web servers) and Standard HDD (backups, dev/test). Premium and Standard SSD also come in ZRS versions that survive a zone failure.
Add, change and grow disks
Portal: VM › Settings › Disks › + Create and attach a new disk (or Attach existing disks), set the LUN, type, size and Host caching, then Save.
az vm disk attach -g rg-contoso-prod --vm-name vm-app-01 -n vm-app-01-data1 \
--new --size-gb 128 --sku Premium_LRS --caching ReadOnly
az vm disk detach -g rg-contoso-prod --vm-name vm-app-01 -n vm-app-01-data1
az disk update -g rg-contoso-prod -n vm-app-01-data1 --sku StandardSSD_LRS --size-gb 256
$vm = Get-AzVM -ResourceGroupName rg-contoso-prod -Name vm-app-01
$cfg = New-AzDiskConfig -Location eastus -CreateOption Empty -DiskSizeGB 128 -SkuName Premium_LRS
$disk = New-AzDisk -ResourceGroupName rg-contoso-prod -DiskName vm-app-01-data1 -Disk $cfg
Add-AzVMDataDisk -VM $vm -Name vm-app-01-data1 -ManagedDiskId $disk.Id -Lun 0 -CreateOption Attach -Caching ReadOnly
Update-AzVM -VM $vm -ResourceGroupName rg-contoso-prod
| Change | VM running? |
|---|---|
| Attach or detach a data disk | Yes (unmount it in the OS before detaching) |
| Grow a data disk | Yes, in most cases, then extend the partition |
| Grow the OS disk | Deallocate first |
| Change disk type (Premium ↔ Standard) | Deallocate the VM or detach the disk |
| Shrink a disk | Not possible |
| Max data disks | Set by the VM size |
Host caching: ReadOnly suits read-heavy data such as database data files, None suits write-heavy logs, and ReadWrite is only safe when the app writes through properly. The OS disk defaults to ReadWrite.
Encryption options
| Option | Covers | Keys | Notes |
|---|---|---|---|
| Server-side encryption (SSE) | Managed disks at rest in Storage | Platform-managed by default, or customer-managed via a disk encryption set | Always on |
| Encryption at host | Temp disk, OS/data disk caches, data in flow to Storage | Same keys as SSE | Runs on the host, no VM CPU cost |
| Azure Disk Encryption (ADE) | Volumes inside the guest OS | Key Vault | BitLocker/DM-Crypt; retires on 15 September 2028, so use encryption at host for new VMs |
| Confidential disk encryption | OS disk bound to the VM’s TPM | Platform or customer key | Confidential VM sizes only |
Turn on encryption at host
# once per subscription
az feature register --name EncryptionAtHost --namespace Microsoft.Compute
az feature show --name EncryptionAtHost --namespace Microsoft.Compute --query properties.state
az provider register --namespace Microsoft.Compute
# new VM
az vm create ... --encryption-at-host true
# existing VM: must be deallocated
az vm deallocate -g rg-contoso-prod -n vm-app-01
az vm update -g rg-contoso-prod -n vm-app-01 --set securityProfile.encryptionAtHost=true
az vm start -g rg-contoso-prod -n vm-app-01
In the portal: Disks tab of the create wizard › Encryption at host, or on an existing deallocated VM Disks › Additional settings › Encryption at host: Yes. The VM size has to support it, and the VM can’t also use ADE.
Architect level Picking disk performance
On Premium SSD, performance grows with size tiers (P10 = 128 GiB with about 500 IOPS, P30 = 1 TiB with about 5,000), so people sometimes buy a bigger disk just for IOPS. Premium SSD v2 and Ultra Disk let you set capacity, IOPS and throughput separately, and change performance without a restart. Remember the VM size caps total disk IOPS and throughput too: four fast disks on a small VM are limited by the VM, not the disks. Snapshots (az snapshot create) give point-in-time copies of a disk for backups or cloning.
Real-world business scenario
Woodgrove Bank (fictional)
- The problem
- An audit found that the page file and disk caches on payment VMs weren't covered by the bank's encryption policy, and premium disks were paid for on archive servers nobody read.
- What they used
- The team registered EncryptionAtHost, enabled it on each VM during a maintenance window (deallocate, update, start) with customer-managed keys through a disk encryption set, and switched archive data disks from Premium SSD to Standard HDD.
- Why that choice
- Encryption at host covers the temp disk and caches on the host without using VM CPU, and disk types can be changed in place while the VM is deallocated.
- The result
- The audit finding was closed, and disk costs on the archive servers dropped by more than half.
When to use it and when not to
✓ Use it when…
- Separate data disks for application data, so the OS disk can be rebuilt or swapped.
- Encryption at host when policy needs the temp disk and caches encrypted.
- Changing disk types to match how busy each disk really is.
✕ Think twice when…
- Storing anything you need on the temporary disk.
- Encryption at host on a VM that already uses Azure Disk Encryption. Pick one.
↔ Alternatives to consider
- Customer-managed keys through a disk encryption set for your own key control.
- Azure Files when several VMs must share the same files.
- Premium SSD v2 when you need high IOPS without paying for extra capacity.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between the OS disk, a data disk and the temp disk?
Model answer
The OS disk holds the operating system. Data disks hold application data, and both are managed disks that survive restarts and deallocation. The temp disk sits on the physical host. It's fast but anything on it can disappear when the VM moves hosts, so it's only for page files and scratch data.
Intermediate How do you switch a data disk from Premium SSD to Standard SSD?
Model answer
Deallocate the VM, or detach the disk, then change the SKU on the disk's Size + performance blade or with az disk update --sku StandardSSD_LRS. Then start the VM again. You can't change the type of an attached disk while the VM is running.
Experienced developer Managed disks are already encrypted. Why would you turn on encryption at host?
Model answer
Server-side encryption covers the disks at rest in Storage. It doesn't cover the temp disk or the disk cache that live on the host. Encryption at host encrypts those on the host itself and sends data to Storage already encrypted, which is what auditors usually mean by end-to-end. It doesn't use the VM's CPU, unlike Azure Disk Encryption.
Scenario You try to enable encryption at host on a VM and the option is greyed out. What do you check?
Model answer
First whether the EncryptionAtHost feature is registered on the subscription with az feature register and az provider register. Then whether the VM is deallocated, because the setting can't change while it runs. Then whether the VM size supports it and whether the VM uses Azure Disk Encryption, which blocks it.
Quick revision
Key points
- OS and data disks are managed disks; the temp disk is on the host and isn't persistent.
- Attach and detach data disks while the VM runs. Grow disks, never shrink them.
- Changing a disk type needs the VM deallocated or the disk detached.
- Host caching - ReadOnly for read-heavy data, None for write-heavy logs, ReadWrite only if the app handles it.
- Encryption at host - register EncryptionAtHost, deallocate, enable, start. Covers temp disk and caches.
Important terminology
- Managed disk
- A block storage volume for a VM that Azure stores, replicates and encrypts for you, such as an OS or data disk.
- Temporary disk
- Local storage on the VM's host (D on Windows, often /mnt on Linux). Data on it is lost after deallocation, redeployment or host maintenance.
- Host caching
- A per-disk cache on the host. None, ReadOnly or ReadWrite. Not available for Ultra Disk or Premium SSD v2.
- Server-side encryption (SSE)
- Encryption at rest of managed disks in Azure Storage, on by default, with platform-managed or customer-managed keys.
- Encryption at host
- Encryption of the temp disk and OS/data disk caches on the VM host, so data is encrypted from the host to Storage.
- Disk encryption set
- The resource that links managed disks to a customer-managed key in Azure Key Vault.
- Azure Disk Encryption (ADE)
- Older guest-OS encryption with BitLocker or DM-Crypt and Key Vault. It can't be combined with encryption at host on the same VM.
Common mistakes
- Keeping important data on the temporary disk.
- Trying to enable encryption at host on a running VM, or on a VM that uses Azure Disk Encryption.
Exam tips
- "Encrypt the temp disk and caches" = encryption at host.
- "Use your own key for disk encryption at rest" = customer-managed key with a disk encryption set.
- "Data lost after the VM was deallocated" = it was on the temporary disk.
Five quick revision questions
-
1.Which command attaches a new data disk to a VM?Show
az vm disk attach --new --size-gb <n>.
-
2.Which feature must be registered before using encryption at host?Show
Microsoft.Compute/EncryptionAtHost.
-
3.What VM state is needed to turn on encryption at host for an existing VM?Show
Stopped (deallocated).
-
4.Can you shrink a managed disk?Show
No, disks can only grow.
-
5.Which disk is lost when a VM is redeployed to a new host?Show
The temporary disk.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Move a VM to Another Resource Group, Subscription or Region
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.