Create Managed Disk from VHDx Blob
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 createddiskName
: name of the diskstorageType
: storage type for the disk, i.e. Standard_LRS, Premium_LRS,UltraSSD_LRSlocation
: region where the disk will be createddiskSize
: size of the diskvhdUri
: 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