Converting OVA / VMDK to VHD for use in Azure

Software required:


Virtualbox: (Or you could use which is less to install)

Azure PowerShell:

Azure Storage Explorer:

Install the software listed above. Azure Storage Explorer isn’t needed but makes it a lot easier to both upload and move files between storage accounts.

Converting the file

Rename the OVA-file to filename.TAR, unpack it with 7-zip so that you get the VMDK-file in a directory.

Start a command prompt (CMD.exe) and navigate to the “C:\Program Files\Oracle\Virtualbox” directory

Using vboxmanage.exe we’ll convert our file to VHD.

Once it’s done we’ll need to upload it to Azure.

Create a storage account in the portal

See for instructions.

Create a blob container

Using Azure Storage Explorer you can create a blob container.

Upload the VHD

Click the upload button and select “Upload Files”. Select one or more VHD-files to upload


Click “Upload” and wait for it to complete.

Deploying your virtual machine

For the script to work you will need an existing Resource Group containing a virtual network.

You will need to replace the variables with the settings for your deployment.

From storage explorer you can copy the storage account name and osDiskURI.

Click your storage account that you uploaded the files to:

The name of the storage account can be found at the bottom.

Click your blob container

The URL is found at the bottom and the URI is made up of URL + filename, in this example it’s azurevm.vhd. So the URI would be “”

The rest of the variables can be found in the portal.

Copy the below script to the editor of your choice. I prefer Notepad++ or PowerShell ISE.

$RGName                	= "resourcegroupname"
$storageAccName        	= "storageaccountname"
$ComputerName          	= "Computer name"
$osDiskName            	= "name-of-osdisk"
$osDiskUri 			= ""
$location              	= "West Europe"
$vmName                	= "vm name"
$vmSize 			= "Standard_A2"
$cred 				= Get-Credential
$vnetName			= "existing vnet name"
$vnet=Get-AzureRMVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$nicName="nic name"
$pip=New-AzureRmPublicIpAddress -Name $nicName -ResourceGroupName $rgName -Location $location -AllocationMethod Dynamic -Force
$nic=New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[$subnetIndex].Id -PublicIpAddressId $pip.Id -Force
$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $rgName -AccountName $storageAccName
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
$vm = Add-AzureRmVMNetworkInterface -VM $vmConfigget -Id $nic.Id
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption attach -Linux
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm -Verbose


Edit the script with your parameters.

Use Add-AzureRMAccount to login to your subscription.

Run the script in PowerShell.

The script will only work for Linux virtual machines.

Once the script is done your vm is deployed to Azure.

Leave a Reply

Your email address will not be published. Required fields are marked *