Although there are many ways to upload an image file to Azure (including GUI based tools) but I think Powershell is still the best and the most efficient option.
Why? because of the following reasons:
- Add-AzureVHD commandlet automatically converts a VHDX file to VHD during upload. This is useful since Windows Azure only supports VHD for now.
- Add-AzureVHD is “aware” of the VHD format and so copies only the bytes that contain data and skips the empty ones. This saves a lot of time – it took 10 minutes to upload a file with Add-AzureVHD vs. 80 minutes for the same file with another GUI based tool.
- Add-Azure also uses a checksum to verify the integrity of the uploaded file.
Hopefully by now you are convinced and are asking how to do it. Well, it’s really simple but before you actually do it, make sure that the VM image that you are about to upload is set to use DHCP and that Remote Desktop is enabled otherwise you will not be able to connect to it. The same applies to Linux based machines, but SSH needs to be working instead of RDP.
Lets’ get to it…
First you have to download and install the Windows Azure PowerShell module by running the Microsoft Web Platform Installer.
Then you need to configure your Windows Azure Subscription by following the following steps:
- Launch Windows Azure PowerShell
- In the powershell prompt, type the following
- Import-AzurePublishSettingsFile “C: Subscription-1-1-10-2014-credentials.publishsettings”
To upload an image, follow the steps below:
- $sourceVHD = “D:Virtual Hard DisksWindows2012.vhd” <enter>
- $destinationVHD = “https://abc.blob.core.windows.net/vhds/MyWindows2012.vhd” <enter>
- Add-AzureVhd -LocalFilePath $sourceVHD -Destination $destinationVHD -NumberOfUploaderThreads 3 <enter>
To make the uploaded image usable you can continue to use the powershell, but I prefer the GUI for this task (unless scripting):
- login to your Azure account at https://manage.windowsazure.com
- click on the “VIRTUAL MACHINES” tab
- Click on “DISKS”
- Then click on “CREATE”
- Fill out the “NAME” and browse for the VHD URL and pick the file just uploaded
- Make sure that “The VHD contains an operating system.” is checked
- Click “OK”
Now you can create a virtual machine using the uploaded vhd file by “creating a virtual machine from the gallery” and then picking “MY DISKS”
Thank you for reading – visit often for new tit-bits !!!
You can download a VHD by running the following powershell commands:
$destinationVHD = “D:Virtual Hard DisksWindows2012.vhd” <enter>
$sourceVHD = “https://abc.blob.core.windows.net/vhds/MyWindows2012.vhd” <enter>
Save-AzureVhd -Source $sourceVHD -LocalFilePath $destinationVHD -NumberOfThreads 3