About VHDs in Azure
Updated: March 27, 2015
All images and disks in Azure, except the temporary disk, are actually virtual hard disks (VHDs). The virtual hard disks are .vhd files stored as page blobs in a standard or premium storage account in Azure. (Premium storage is in Preview and is available in certain regions.) For details about page blobs, see Understanding Block Blobs and Page Blobs. For details about premium storage, see Premium Storage: High-Performance Storage for Azure Virtual Machine Workloads.
Outside of Azure, virtual hard disks can use either a VHD or a VHDX format. They can also be fixed, dynamically expanding, or differencing. Azure supports VHD format, fixed disks. The fixed format lays the logical disk out linearly within the file, so that disk offset X is stored at blob offset X. A small footer at the end of the blob describes the properties of the VHD. Often, the fixed format wastes space because most disks have large unused ranges in them. However, Azure stores .vhd files in a sparse format, so you receive the benefits of both the fixed and dynamic disks at the same time. For more information about VHDs, see Getting Started with Virtual Hard Disks.
All .vhd files in Azure that are intended for use as a source for creating disks or images are read only. When you create a disk or image, Azure makes copies of the .vhd files. These copies can be read only or read and write, depending on how you use the VHD.
You can use your own VHD that contains an operating system or data by uploading the VHD to an Azure storage account. Various tools are available to create VHDs. For example, you can use Hyper-V or the Disk Management snap-in available in recent versions of Windows. To upload the disk, use Add-AzureVHD. This cmdlet is available in the Azure PowerShell module. You can download the module from the “Command Line Tools” section of the Downloads page on WindowsAzure.com.
|If your VHD is a dynamic disk, convert it to a fixed disk before you try to upload it. You can use Hyper-V Manager or the convert-vhd cmdlet to do this.|
After you upload a VHD, you can use it as a source to create an image or operating system disk. Or, if it contains data, you can attach it to a virtual machine as a data disk. For instructions, see:
The .vhd files are stored as page blobs. Several tools are available for you to use to manage blobs in storage.
You can use elements in the Blob Service Rest API to work with blobs in storage. For more information, see Operations on Blobs. You can also copy blobs across storage accounts. For more information about copying blobs, see Introducing Asynchronous Cross-Account Copy Blob.
|Only storage accounts created on or after June 7th, 2012 allow the Copy Blob operation to copy from another storage account.|
When you create a virtual machine from an image, Azure creates a disk for the virtual machine that is a copy of the source .vhd file. To protect against accidental deletion, Azure places a lease on any source .vhd file that’s used to create an image, an operating system disk, or a data disk.
Before you can delete a source .vhd file, you’ll need to remove the lease by deleting the disk or image. To delete a .vhd file that is being used by a virtual machine as an operating system disk, you can delete the virtual machine, the operating system disk, and the source .vhd file all at once by deleting the virtual machine and deleting all associated disks. However, deleting a .vhd file that’s a source for a data disk requires several steps in a set order -- detach the disk from the virtual machine, delete the disk, and then delete the .vhd file.