Non timetis messor

Migrating a VMware VM to Azure

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

  1. Open the Visual Studio Command Line Prompt as an Administrator
  2. Execute the following command:
    makecert -sky exchange -r -n “CN=<CertificateName>” -pe -a sha1 -len 2048 -ss My “<CertificateName>.cer”
  3. Browse to C:\Windows\SysWOW64 and locate the .cer that was just created.

Note: If you get an error CryptCertStrToNameW failed => 0×80092023 (-2146885597), delete and retype all of the double-quotes in the command.

Add a Management Certificate

  1. Sign into Windows Management Portal
  2. Click on Preview and then Take me to Previous Portal (Note: this is probably a temporary step while Microsoft spins up its IaaS implementation).
  3. Click on Hosted Services, Storage Accounts & CDN
  4. Click on Management Certificates
  5. Click Add Certificate
  6. Click Browse and browse to the .cer file created in the previous step.

Get Account Login Details

  1. While in the Management Certificates section, select the thumbprint (ex. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) and copy/paste it somewhere safe
  2. 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.

  1. 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.
  2. 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.
  3. Uninstall VMware tools- if you have installed the VMWare tools, remove them.
  4. Enable Remote Desktop Access – you will want to enable remote desktop connections and make sure that they are permitted through the firewall (if enabled).
  5. Install the Hyper-V Role
  6. 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.

  1. Open the Azure Command Line Prompt
  2. Execute the following commands:

    csupload Set-Connection “SubscriptionId=SubscriptionId;CertificateThumbprint=CertThumbprint;ServiceManagementEndpoint=https://management.core.windows.net”

    Note
    : Use the SubscriptionId and Thumbprint noted earlier 

    csupload 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.

  1. Click New (Bottom Left)
  2. Select Virtual Machine then From Gallery
  3. Select My Images
  4. You should now see your image listed. Configure your machine as needed.
  5. Once complete, Azure will begin creating and provisioning your VM.
  6. After your VM has been provisioned, click Connect and save the .rdp file where ever you like
  7. 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.

3 comments

  1. Ayman Ali /

    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:\>

    • Chris Hettinger /

      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.

  2. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>