Download a Windows VHD from Azure

Applies to: ✔️ Windows VMs

This article explains how to download a Windows virtual hard disk (VHD) file from Azure. To download a VHD, the disk can't be attached to a running VM, which means the VM experiences downtime. However, some configurations can safely avoid downtime by snapshotting the disk and downloading the VHD from the snapshot.

If you're using Microsoft Entra ID to control resource access, you can use it to restrict uploading of Azure Managed Disks. For more information, see Secure downloads and uploads of Azure Managed Disks.

Optional: Generalize the VM

If you want to use the VHD as an image to create other VMs, use Sysprep to generalize the operating system. Otherwise, you need to make a copy of the disk for each VM you want to create.

To use the VHD as an image to create other VMs, generalize the VM.

  1. Sign in to the Azure portal.
  2. Connect to the VM.
  3. On the VM, open the Command Prompt window as an administrator.
  4. Change the directory to %windir%\system32\sysprep and run sysprep.exe.
  5. In the System Preparation Tool dialog box, select Enter System Out-of-Box Experience (OOBE), and make sure that Generalize is selected.
  6. In Shutdown Options, select Shutdown, and then select OK.

If you don't want to generalize your current VM, you can still create a generalized image by first making a snapshot of the OS disk, creating a new VM from the snapshot, and then generalizing the copy.

Stop the VM

You can't download a VHD from Azure if it's attached to a running VM. If you want to keep the VM running, you can create a snapshot and then download the snapshot.

  1. On the Hub menu in the Azure portal, select Virtual Machines.
  2. Select the VM from the list.
  3. On the blade for the VM, select Stop.

Alternative: Snapshot the VM disk

Note

If feasible, stop a VM before taking a snapshot of it, otherwise the snapshot isn't clean. Snapshots of running VMs are in the same state as if their VMs were power cycled or crashed when you take a snapshot. Usually this state is safe but, it could cause problems if the running applications aren't crash resistant.

Generally, you should only use snapshots of running VMs if the only disk associated with them is a single OS disk. If a VM has one or more data disks, stop the VM before creating a snapshot of the OS or data disks.

Take a snapshot of the disk to download.

  1. Select the VM in the portal.
  2. Select Disks in the left menu and then select the disk you want to snapshot. The details of the disk are displayed.
  3. Select Create Snapshot from the menu at the top of the page. The Create snapshot page opens.
  4. In Name, type a name for the snapshot.
  5. For Snapshot type, select Full or Incremental.
  6. When you're done, select Review + create.

Your snapshot is created shortly, and you can then use it to download or create another VM.

Generate download URL

To download the VHD file, you need to generate a shared access signature (SAS) URL. When you generate the URL, you assign an expiration time to it.

Important

On February 15th, 2025, the Shared Access Signature (SAS) access time for disks and snapshots will be limited to a maximum of 60 days. Trying to generate a SAS with an expiration longer than 60 days results in an error. Any existing disk or snapshot SAS created with an expiration longer than 60 days may stop working 60 days after the date of creation and will result in a 403 error during authorization.

If a managed disk or snapshot SAS's expiration is longer than 60 days, revoke its access, and generate a new SAS that requests access for 60 days (5,184,000 seconds) or less. Improve your overall security by using SAS with shorter expiration dates. Make these changes before February 15, 2025 to prevent service interruption. The following links can be used to find, revoke, and request a new SAS.

  1. On the page for the VM, select Disks in the left menu.
  2. Select the operating system disk for the VM.
  3. On the page for the disk, select Disk Export from the left menu.
  4. The default expiration time of the URL is *3,600 seconds (one hour). You might need to increase this value for Windows OS disks or large data disks. In these situations, 36000 seconds (10 hours) is usually sufficient.
  5. Select Generate URL.

Note

When downloading a Windows OS disk, you might need a longer expiration time to download a large VHD file. Large VHDs can take up to several hours to download depending on your connection and the size of the VM.

While the SAS URL is active, attempting to start the VM results in the error There is an active shared access signature outstanding for disk diskname. You can revoke the SAS URL by selecting Cancel export on the Disk Export page.

Download VHD

Note

If you're using Microsoft Entra ID to secure managed disk downloads, the user downloading the VHD needs the appropriate RBAC permissions.

  1. Under the generated URL, select Download the VHD file.
  2. You might need to select Save in your browser to start the download. The default name for the VHD file is abcd.

Next steps