One of the great features of Windows Azure is VHD mobility. Simply put it means you can upload and download VHDs to and from the cloud.
Note:if you is used to the using CSUpload.exe for uploading VHDs the should switch to PowerShell. CSUpload.exe has been marked as deprecated and would likely not ship in the future SDKs.
Technical Notes
A few things to point off while I ' m here. Currently, Windows Azure only supports the VHD file format in a fixed disk format.
That is being said the Add-azurevhd cmdlet supports converting a dynamic VHD on upload to a fixed VHD so does not has to W Orry about converting them up front.
Also, both the add-azurevhd and save-azurevhd cmdlets have intrinsic knowledge of the VHD file format and during upload or Download only copy the written bytes and skip the empty. This is a huge optimization!
So let's jump right in using PowerShell. This page assumes your PowerShell client are already setup to access your Windows Azure subscription. If This isn't the case, read through the Getting Started with Windows Azure PowerShell Cmdlets first.
Uploading a VHD
Import-module azureselect-azuresubscription "mysubscriptionname" $sourceVHD = "D:\StorageDemos\myvhd.vhd" $ Destinationvhd = "Https://mwwestus1.blob.core.windows.net/uploads/myvhd.vhd" Add-azurevhd-localfilepath $sourceVHD -destination $destinationVHD ' -numberofuploaderthreads 5 |
As you can see the code to upload a VHDs to your Windows Azure Storage account are pretty simple.
To make the VHD usable your need to register it with Windows Azure.
Register VHD as a Data Disk
# Register as a plan old data disk add-azuredisk-diskname ' Mydatadisk '-medialocation $destinationVHD ' -label ' Mydat Adisk ' |
When the code above is run the uploaded VHD would be registered in Windows Azure as a data disk named ' Mydatadisk '. Refresh the portal and you'll see it in the Disks list and it'll also be available for attaching to a vsan.
If you is uploading a VHD with an operating system on it you need to tell this to Windows Azure.
Register VHD as an OS Disk
This code registers the disk as bootable. Meaning you can now create a Vsan and specify this disk as the boot disk.
# Register as a plan old data disk add-azuredisk-diskname ' Myosdisk '-medialocation $destinationVHD ' -label ' Myosdis K '-os Windows # or Linux |
Creating a VM from uploaded VHDs
As I mentioned above you can specify a disk to boot from instead of provisioning from an image. The PowerShell code to does is simple. You can of course add disks and endpoints in between New-azurevmconfig and NEW-AZUREVM as well.
New-azurevmconfig-diskname ' Myosdisk '-name ' myvm1 '-instancesize Small | Add-azuredatadisk-import-diskname ' Mydatadisk '-lun 0 | New-azurevm-servicename ' mycloudsvc '-location ' West US ' |
Now it's seen how to upload VHD's to the cloud let's walk through the equally simple download process.
Downloading a VHD from Windows Azure
The same pattern as add-azurevhd just reversed!
Select-azuresubscription "Mysubscriptionname" $sourceVHD = "https://mwwestus1.blob.core.windows.net/uploads/ Mydatadisk.vhd "$destinationVHD =" D:\StorageDemos\mydatadisk-downloaded.vhd "Save-azurevhd-source $sourceVHD- Localfilepath $destinationVHD ' -numberofthreads 5 |
That ' s it! Uploading and downloading VHDs to Windows Azure are fast and simple.
Windows uploads VMS