Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 23 of 47
❮Prev Next❯

VM Disks and Encryption at Host

Module 3: Compute ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Add a data disk, change a disk tier and turn on encryption at host Attach a disk, turn on encryption at host and change a disk tier.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Encryption at host must be registered once per subscription. Do it in Cloud Shell (or under Subscriptions › Preview features).
    2. Open vm-app-01. It's Stopped (deallocated), which encryption at host needs before you can switch it on. Open Settings › Disks.
    3. The OS disk is listed first. Under Data disks, select + Create and attach a new disk.
    4. Name it, keep Premium SSD, set 128 GiB and Read-only caching, then Save. Data disks can also be attached while the VM runs.
    5. 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.
    6. 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.
    7. 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.

    😟 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
    🛠️ Solved with: Managed disks and encryption at host

    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

    DiskWhere it livesSurvives deallocation?Use it for
    OS diskManaged disk in Azure StorageYesThe operating system
    Data diskManaged disk in Azure StorageYesDatabases, app files, logs
    Temporary diskLocal storage on the hostNoPage 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
    ChangeVM running?
    Attach or detach a data diskYes (unmount it in the OS before detaching)
    Grow a data diskYes, in most cases, then extend the partition
    Grow the OS diskDeallocate first
    Change disk type (Premium ↔ Standard)Deallocate the VM or detach the disk
    Shrink a diskNot possible
    Max data disksSet 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

    OptionCoversKeysNotes
    Server-side encryption (SSE)Managed disks at rest in StoragePlatform-managed by default, or customer-managed via a disk encryption setAlways on
    Encryption at hostTemp disk, OS/data disk caches, data in flow to StorageSame keys as SSERuns on the host, no VM CPU cost
    Azure Disk Encryption (ADE)Volumes inside the guest OSKey VaultBitLocker/DM-Crypt; retires on 15 September 2028, so use encryption at host for new VMs
    Confidential disk encryptionOS disk bound to the VM’s TPMPlatform or customer keyConfidential 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

    Financial services

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    Company policy requires that the temporary disk and the OS and data disk caches of VM1 are encrypted. VM1 uses managed disks with server-side encryption and platform-managed keys.

    What should you enable?

    Question 2

    Question 2 of 5 · Select 2

    You plan to enable encryption at host on an existing running virtual machine named VM1. The feature has never been used in the subscription.

    Which two actions must you perform before you can enable encryption at host on VM1? Each correct answer presents part of the solution.

    Question 3

    Question 3 of 5

    VM1 is running and has a 128 GiB Premium SSD data disk named Disk1. You need to change Disk1 to Standard SSD.

    What should you do first?

    Question 4

    Question 4 of 5

    A VM was deallocated and then started. Files that an application saved to drive D: are missing, but files on drive C: and on a data disk mounted as F: are intact. What is the most likely cause?

    Question 5

    Question 5 of 5

    You need to add a new 256 GiB Premium SSD data disk to a running Linux VM named VM1 without restarting it. Which command should you run?

    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. 1.Which command attaches a new data disk to a VM?Show

      az vm disk attach --new --size-gb <n>.

    2. 2.Which feature must be registered before using encryption at host?Show

      Microsoft.Compute/EncryptionAtHost.

    3. 3.What VM state is needed to turn on encryption at host for an existing VM?Show

      Stopped (deallocated).

    4. 4.Can you shrink a managed disk?Show

      No, disks can only grow.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.