How to upload VHDX\VHD to Azure and use it for an Azure VM

PreReq’s

  • You need to have the HyperV Role installed on the server if you want to convert VHDX -> VHD , Azure only support VHD
  • You need to create a storage account in Azure : $storageaccount
  • You need to create a container in that storage account $containername
  • Azure Resource Group : $resourceGroup
  • VHD to VHDX should be stored at $localPath e.g. C:\Temp\VHD.VHD – this should be the C drive of the computer including System Reserve partition

 

  1. Connect to Azure

connect-azaccount

2. Select Azure Subscription

Select-AzureSubscription -Current -SubscriptionName $AzureSubscriptionName

3. 
# Upload the VHD
$urlOfUploadedImageVhd = (‘https://$storageaccount.blob.core.windows.net/’ + $containername + ‘/’ + $vhdName)
Add-AzVhd -ResourceGroupName $resourceGroup -Destination $urlOfUploadedImageVhd -LocalFilePath $localPath

This will try and convert the VHDX file to VHD

To be compatible with Azure, Add-AzVhd will automatically try to convert VHDX files to VHD, and resize VHD files to N * Mib using Hyper-V Platform, a Windows naitive virtualization product.
For more information visit https://aka.ms/usingAdd-AzVhd

MD5 hash is being calculated for the file \\XXXX\f$\TEMP\XXXX.VHD.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:16:32
Creating new page blob of size 68719477248…
Detecting the empty data blocks in the local file.
Detecting the empty data blocks completed.
Elapsed time for upload: 00:32:37

LocalFilePath DestinationUri
————- ————–
\\vbr01\f$\TEMP\XXXX.VHD https://$storageaccount.blob.core.windows.net/$containername/XXXX.VHD

You will have the new Blob URL for the VHD, now you need to make a managed disk from it – https://aidanfinn.com/?p=20441

Once you have a managed disk you can then create a VM from that Managed Disk

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...