Move a Windows VM from Amazon Web Services (AWS) to Azure using PowerShell

If you are evaluating Azure virtual machines for hosting your workloads, you can export an existing Amazon Web Services (AWS) EC2 Windows VM instance then upload the virtual hard disk (VHD) to Azure. Once the VHD is uploaded, you can create a new VM in Azure from the VHD.

This topic covers moving a single VM from AWS to Azure. If you want to move VMs from AWS to Azure at scale, see Migrate virtual machines in Amazon Web Services (AWS) to Azure with Azure Site Recovery.

Prepare the VM

You can upload both generalized and specialized VHDs to Azure. Each type requires that you prepare the VM before exporting from AWS.

  • Generalized VHD - a generalized VHD has had all of your personal account information removed using Sysprep. If you intend to use the VHD as an image to create new VMs from, you should:

  • Specialized VHD - a specialized VHD maintains the user accounts, applications and other state data from your original VM. If you intend to use the VHD as-is to create a new VM, ensure the following steps are completed.

    • Prepare a Windows VHD to upload to Azure. Do not generalize the VM using Sysprep.
    • Remove any guest virtualization tools and agents that are installed on the VM (i.e. VMware tools).
    • Ensure the VM is configured to pull its IP address and DNS settings via DHCP. This ensures that the server obtains an IP address within the VNet when it starts up.

Export and download the VHD

Export the EC2 instance to a VHD in an Amazon S3 bucket. Follow the steps described in the Amazon documentation topic Exporting an Instance as a VM Using VM Import/Export and run the create-instance-export-task command to export the EC2 instance to a VHD file.

The exported VHD file is saved in the Amazon S3 bucket you specify. The basic syntax for exporting the VHD is below, just replace the placeholder text in with your information.

aws ec2 create-instance-export-task --instance-id <instanceID> --target-environment Microsoft \
  --export-to-s3-task DiskImageFormat=VHD,ContainerFormat=ova,S3Bucket=<bucket>,S3Prefix=<prefix>

Once the VHD has been exported, follow the instructions in How Do I Download an Object from an S3 Bucket? to download the VHD file from the S3 bucket.

Important

AWS charges data transfer fees for downloading the VHD. See Amazon S3 Pricing for more information.

Next steps

Now you can upload the VHD to Azure and create a new VM.