{"id":5505,"date":"2022-01-24T23:06:30","date_gmt":"2022-01-24T23:06:30","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=5505"},"modified":"2022-01-24T23:06:30","modified_gmt":"2022-01-24T23:06:30","slug":"how-to-upload-vhdxvhd-to-azure-and-use-it-for-an-azure-vm","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/how-to-upload-vhdxvhd-to-azure-and-use-it-for-an-azure-vm","title":{"rendered":"How to upload VHDX\\VHD to Azure and use it for an Azure VM"},"content":{"rendered":"<p>PreReq&#8217;s<\/p><ul><li>You need to have the HyperV Role installed on the server if you want to convert VHDX -&gt; VHD , Azure only support VHD<\/li><li>You need to create a storage account in Azure : $storageaccount<\/li><li>You need to create a container in that storage account $containername<\/li><li>Azure Resource Group : $resourceGroup<\/li><li>VHD to VHDX should be stored at $localPath e.g. C:\\Temp\\VHD.VHD &#8211; this should be the C drive of the computer including System Reserve partition<\/li><\/ul><p>&nbsp;<\/p><ol><li>Connect to Azure<\/li><\/ol><p>connect-azaccount<\/p><p>2. Select Azure Subscription<\/p><p><span class=\"hljs-pscommand\">Select-AzureSubscription<\/span><span class=\"hljs-parameter\"> -Current<\/span><span class=\"hljs-parameter\"> -SubscriptionName<\/span> $AzureSubscriptionName<\/p><p>3.\u00a0<br \/># Upload the VHD<br \/>$urlOfUploadedImageVhd = (&#8216;https:\/\/$storageaccount.blob.core.windows.net\/&#8217; + $containername + &#8216;\/&#8217; + $vhdName)<br \/>Add-AzVhd -ResourceGroupName $resourceGroup -Destination $urlOfUploadedImageVhd -LocalFilePath $localPath<\/p><p>This will try and convert the VHDX file to VHD<\/p><p style=\"padding-left: 40px;\">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.<br \/>For more information visit https:\/\/aka.ms\/usingAdd-AzVhd<\/p><p style=\"padding-left: 40px;\">MD5 hash is being calculated for the file \\\\XXXX\\f$\\TEMP\\XXXX.VHD.<br \/>MD5 hash calculation is completed.<br \/>Elapsed time for the operation: 00:16:32<br \/>Creating new page blob of size 68719477248&#8230;<br \/>Detecting the empty data blocks in the local file.<br \/>Detecting the empty data blocks completed.<br \/>Elapsed time for upload: 00:32:37<\/p><p style=\"padding-left: 40px;\">LocalFilePath DestinationUri<br \/>&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\\\\vbr01\\f$\\TEMP\\XXXX.VHD https:\/\/$storageaccount.blob.core.windows.net\/$containername\/XXXX.VHD<\/p><p>You will have the new Blob URL for the VHD, now you need to make a managed disk from it &#8211; <a href=\"https:\/\/aidanfinn.com\/?p=20441\">https:\/\/aidanfinn.com\/?p=20441<\/a><\/p><p>Once you have a managed disk you can then create a VM from that Managed Disk<\/p>","protected":false},"excerpt":{"rendered":"<p>PreReq&#8217;sYou need to have the HyperV Role installed on the server if you want to convert VHDX -&gt; VHD , Azure only support VHDYou need to create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1464,1145,3246,2256,3702,3231],"class_list":["post-5505","post","type-post","status-publish","format-standard","hentry","category-research","tag-azure","tag-disk","tag-upload","tag-vhd","tag-vhdx","tag-vm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=5505"}],"version-history":[{"count":2,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5505\/revisions"}],"predecessor-version":[{"id":5507,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5505\/revisions\/5507"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=5505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=5505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=5505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}