Life's random bits By b1thunt3r (aka Ishan Jain)…
Create Managed Disk from VHDx Blob

Create Managed Disk from VHDx Blob

Ishan jain
Pre-bake you VM image.

Sometimes images provided in Azure Marketplace are not really what you need. It can be an custom linux image or an unsupported (at large, ubt still has some Extended Support in Azure) version of Windows. In some cases you might need to deploy appliances from a pre-baked images.

A while back (like half a decade ago) Azure gave possibility for managed images. Managed Disks comes with some benefits like scalability, performance, High Availability, Snapshots, etc.

In August, it was announced that Microsoft is going to retire un-managed disks on September 30, 2025.

The easiest way I know to deploy VMs in Azure with "bring-your-own-disk" is to upload a disk image to a storage account and attach to a new VM. But to be able to get the additional benefits we need to convert it to managed disk first.

az disk create --resource-group <resourceGroupName> \
--name <diskName> --sku <storageType> --location <location> \
--size-gb $diskSize --source $vhdUri

Where:

  • resourceGroupName: resource group where the disk will be created
  • diskName: name of the disk
  • storageType: storage type for the disk, i.e. Standard_LRS, Premium_LRS,UltraSSD_LRS
  • location: region where the disk will be created
  • diskSize: size of the disk
  • vhdUri: blob url of the source image

For example:

az disk create --resource-group rg-workload01-prod-eastus \
--name vm-workload01-prod-eastus-osdisk \
--sku Standard_ZRS --location eastus --size-gb 128 \
--source $vhdUri https://mystorageaccount.blob.core.windows.net/vhds/workload01-osdisk.vhd

Resources