Convert OVA to VHD for Azure VM
(Updated: )
- 1. Extract VMDK from OVA
- 2. Convert VMDK to VHD
- 3. Upload VHD to Azure Storage
- 4. Create a VM Image or Disk from the Storage Blob
- 5. Create a VM from the VM Image or Disk
OVA (Open Virutal Appliance) is a file format used by VMware for distributing virtual appliance in a single file. If we want to migrate a VM packaged in OVA format to Azure, we'll need to convert it to the VHD (Virtual Hard Disk) format first which is supported by Azure.
1. Extract VMDK from OVA
OVA format is in essence an archive format, we can use software like 7-zip to extract VMDK (Virtual Machine Disk) file(s) from it. The VMDK file is the actual file we need to convert to VHD format.
2. Convert VMDK to VHD
To convert VMDK to VHD, we'll need a tool offered by Microsoft called Microsoft Virtual Machine Converter (MVMC), which provides a PowerShell module to do the conversion.
Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
ConvertTo-MvmcVirtualHardDisk C:\Path\to\Your\Disk.vmdk -VhdType FixedHardDisk -VhdFormat vhd
Note that
-VhdType FixedHardDisk
is important, as only Fixed one is supported, not Dynamic.Note that
-VhdFormat vhd
is important, otherwise the commandlet may produce vhdx file depending on your operating system, and the vhdx format is not supported by Azure.
To get more help on the commandlet, type Get-Help ConvertTo-MvmcVirtualHardDisk
.
3. Upload VHD to Azure Storage
To use the VHD file in Azure as a VM image, we need to upload it as a PageBlob into a blob storage container of an Azure storage account.
Create the storage account and blob container in Portal or use CLI or PowerShell.
Upload can be done with Azure Storage Explorer, or AzCopy, or ConvertTo-MvmcAzureVirtualHardDisk
commandlet provided by MVMC. The ConvertTo-MvmcAzureVirtualHardDisk
commandlet actually combines the conversion and upload steps into one call.
Here is an example using AzCopy v10:
azcopy cp path/to/disk.vhd "https://storageaccount.blob.core.windows.net/container?sas" --blob-type PageBlob
Note that --blob-type PageBlob
is important as only page blob is supported for use as a VM image.
4. Create a VM Image or Disk from the Storage Blob
With the VHD file stored in storage blob, we can create a VM image or managed disk from it depending on whether the original VM where the VHD exports from is generalized or specialized.
- VHD exported from generalized VM can be used to create a VM Image using Portal;
- VHD exported from specialized VM can be used to create a VM Disk using Portal.
5. Create a VM from the VM Image or Disk
Finally, we can create a VM from the image we just created, or attach the Disk just created as OS disk for a new VM.