This document describes the steps necessary to migrate a VMWare virtual machine (.vmx and accompanying .vmdk) to the Microsoft Azure cloud. More detailed documentation is available from Microsoft: Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System and How to Upload a VHD to Windows Azure.
Get the Azure SDK
Download the Microsoft Azure SDK from https://www.windowsazure.com/en-us/develop/downloads/.
Create a Management Certificate
- Open the Visual Studio Command Line Prompt as an Administrator
- Execute the following command:
makecert -sky exchange -r -n “CN=<CertificateName>” -pe -a sha1 -len 2048 -ss My “<CertificateName>.cer” - Browse to C:\Windows\SysWOW64 and locate the .cer that was just created.
Note: If you get an error CryptCertStrToNameW failed => 0x80092023 (-2146885597), delete and retype all of the double-quotes in the command.
Add a Management Certificate
- Sign into Windows Management Portal
- Click on Preview and then Take me to Previous Portal (Note: this is probably a temporary step while Microsoft spins up its IaaS implementation).
- Click on Hosted Services, Storage Accounts & CDN
- Click on Management Certificates
- Click Add Certificate
- Click Browse and browse to the .cer file created in the previous step.
Get Account Login Details
- While in the Management Certificates section, select the thumbprint (ex. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) and copy/paste it somewhere safe
- Click on the Subscription that the certificate belongs to and select the Subscription ID (ex. ########-xxxx-xxxx-xxxx-xxxxxxxxxxxx) and copy/paste it somewhere safe
Setting Up Your VMware Image
There are several changes that should be made (if needed) to your VMware image before it is converted and uploaded to Azure.
- Remove all snapshots – remove any snapshots that you may have. If you do not want to remove snapshots, create a copy of your .vmdk and create a new VMware image that points to it.
- Partition must be IDE – If you have any SCSI Devices, you should convert them to IDE. You may want to use a third party tool to do this such as Acronis.
- Uninstall VMware tools- if you have installed the VMWare tools, remove them.
- Enable Remote Desktop Access – you will want to enable remote desktop connections and make sure that they are permitted through the firewall (if enabled).
- Install the Hyper-V Role
- Run SysPrep Browse to %windir%\system32\sysprep and run sysprep.exe Make sure Enter System Out-of Box Experience (OOBE) is selected and Generalized is checked
Convert VM to VHD
VHD (Virtual Hard Disk) is the only format that Windows Azure supports so it will need to be converted if the image is from VMWare Workstation. There are a variety of tools available for converting images; I found that the StarWind Image Converter worked well.
Upload to Azure, Setup & Connect
Once the VM has been converted to VHD format, it is ready to be imported to Azure.
- Open the Azure Command Line Prompt
- Execute the following commands:
csupload Set-Connection “SubscriptionId=SubscriptionId;CertificateThumbprint=CertThumbprint;ServiceManagementEndpoint=https://management.core.windows.net”
Note: Use the SubscriptionId and Thumbprint noted earliercsupload Add-PersistentVMImage –Destination “<BlobStorageURL>/<YourImagesFolder>/<VHDName>” -Label <VHDName> -LiteralPath <PathToVHDFile> -OS Windows
Note: If you have not created a blob, go to Storage and then New. Once created, select the storage instance to get the BlobStorageURL. You do not have to have an images folder; it will create any path that you enter.
Depending on the size of your image and your upload connection speed, it can take up to several days to upload an image. Once the upload is complete, you can create the VM and connect to it.
- Click New (Bottom Left)
- Select Virtual Machine then From Gallery
- Select My Images
- You should now see your image listed. Configure your machine as needed.
- Once complete, Azure will begin creating and provisioning your VM.
- After your VM has been provisioned, click Connect and save the .rdp file where ever you like
- Execute the .rdp file to connect to the VM
Note: My provisioning failed; however, I was still able to connect to the image and it appeared to be fine. I am in the process of researching this issue.
References
Microsoft. (2012). Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System. Retrieved June 19, 2012, from https://www.windowsazure.com/en-us/manage/windows/common-tasks/upload-a-vhd/. Microsoft. (2012). How to Upload a VHD to Windows Azure. Retrieved June 19, 2012, from http://msdn.microsoft.com/en-us/library/windowsazure/gg465385.aspx.
I followed the guide step by step and succesfuly reached the last step and the vhd started uploading and after one hour I got the following error. Can you please help me. Thanks. Ayman
PS C:\> Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/samaamadeus.vhd -LocalFilePath “\\vm
ware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
MD5 hash is being calculated for the file \\vmware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\
Development7.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:13:52
Creating new page blob of size 214748365312…
Upload failed with exceptions:
Elapsed time for upload: 00:35:47
PS C:\>
PS C:\> Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/samaamadeus.vhd -LocalFilePath “\\vm
ware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
Add-AzureVhd : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/sama …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM
anagement.StorageServices.AddAzureVhdCommand
PS C:\> Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/samaamadeus1.vhd -LocalFilePath “\\v
mware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
Add-AzureVhd : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/sama …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM
anagement.StorageServices.AddAzureVhdCommand
PS C:\> Add-AzureVhd -Destination http://samaamadeus1.blob.core.windows.net/vhdstore/samaamadeus1.vhd -LocalFilePath “\\
vmware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
Add-AzureVhd : ResourceNotFound: The storage account ‘samaamadeus1’ was not found.
At line:1 char:1
+ Add-AzureVhd -Destination http://samaamadeus1.blob.core.windows.net/vhdstore/sam …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.CloudException,Microsoft.WindowsAzure.Commands.ServiceManagement.
StorageServices.AddAzureVhdCommand
PS C:\> Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/samaamadeus.vhd -LocalFilePath “\\vm
ware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
Add-AzureVhd : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/sama …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM
anagement.StorageServices.AddAzureVhdCommand
PS C:\> Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/samaamadeus.vhd -LocalFilePath “\\vm
ware-host\Shared Folders\Documents\Virtual Machines.localized\AmadeusEC2\Development7.vhd” -NumberOfUploaderThreads 32
Add-AzureVhd : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Add-AzureVhd -Destination http://samaamadeus.blob.core.windows.net/vhdstore/sama …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM
anagement.StorageServices.AddAzureVhdCommand
PS C:\>
It has been some time since I have worked with this; however, after reading this it sounds like you may want to ensure that your storage account is in the same subscription using the Set-AzureSubscription command prior.
Hi there,
I’ve got a tool to greatly simplify this task.
It captures a VHD from your server, uploads it to Azure and creates a VM in any region or affinity group, subscription you like.
Move thru a wizard doing all dirty (cert creations, virtual drive conversion, etc) job for you.
See: http://cloudscraper.migrate2iaas.com/azuredownload
It’s in a beta development stage, so it’s free to use.
Thanks in advance for giving it a try!