IT industry today is fast paced compared to any other industries in this century. Growth, Upgrade, Mobility, Availability are the buzz words in today’s world. This is the only industry which is more fashion driven than women’s fashion. With the growth of Cloud Computing, people are moving their existing infrastructure to Cloud. Many tech-giants like Amazon, Microsoft, Google, VMWare are offering their services in cloud computing.
Amazon Web Services and Microsoft Azure are very frequent names for cloud services. Azure argues that its platform allows businesses to fully take advantage of hybrid cloud platforms. Azure Logic Apps works with your existing assets like legacy softwares, ERP, etc and extend it to Azure cloud. Thus with Azure, extensibility is in your control.
Cloud Consultant always get below requirements:
- Moving your on premise Windows Server to Microsoft Azure
- Moving your Amazon EC2 Windows Instance to Microsoft Azure.
- We have configured SharePoint Server or Exchange Server on AWS or on premise.
To setup the same environment on Azure from scratch, might be time consuming or complicated process. So in such cases we will want to migrate preconfigured server to Azure.
To solve the above problem, I’ll take you through the below steps to migrate your AWS or on premise Windows Instance to Azure.
- Clone the EC2 system hard drive to virtual hard drive (VHD) using a utility.
- Run the script to push that VHD to Azure Blob Storage.
- Create a disk from blob storage.
- Create a VM using disk.
Step 1: Creating VHD
First we will convert our system hard drive to VHD so that we can use it to create & launch VM. To convert your EC2 system hard drive to VHD, we will use Disk2VHD utility. Disk2VHD is a free utility that creates VHD from your physical volume for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines.
Into your EC2 instance, download Disk2VHD utility from the below link:
To create VHD go through the following steps:
- Run the Disk2VHD tool on your EC2 instance.
- Uncheck the “Use VHDx” and other option in that tool.
- Select the disc you want to clone. (Generally it will be C drive)
- Give VHD a name & give the path where you want to save the cloned disk.
- Wait till it finish.
Now that VHD is created, we need to push it to Azure. First create storage account, under that storage account we can push VHD under Blob Storage. So to perform that action go through the below steps:
- You need to login to you Azure Portal and create one Storage Account where you will push your VHD.
- Go to storage and create “New”. Provide a name to your storage account and choose the appropriate region you want.
- Make the note of the blob storage URL that you can see on Storage Account Dashboard.
Step 2: Pushing VHD to Azure
Once the VHD is created, run the following script/cmdlets to push it to Azure Blob Storage.
You need Azure PowerShell to run these cmdlets. Click here to download Azure PowerShell.
Run the below cmdlet to add your Azure account.
#A new window will appear in PowerShell where you are supposed to give your Azure Credentials.
After adding Azure Account, we need to select the Subscription where we have created Storage account in step 1. So run the following cmdlet to accomplish that task:
#Give the subscription name that your Azure Account holds. Mine is “Pay-As-You-Go” so I used that one. Replace “Pay-As-You-Go” with your subscription name.
Select-AzureSubscription –SubscriptionName Pay-As-You-Go
Now we are ready to access Azure Services, use the following cmdlet to push the VHD to Azure’s storage account.
#Ignore the <> in below cmdlet.
#Replace <testmachine> with the “Storage Account Name” that you have created in Azure. Also change the <win2012r2> to VHD name you provided while creation of VHD in EC2.
#LocalFilePath is the path where you have saved the VHD or cloned disk.
Set-AzureSubscription –SubscriptionName Pay-As-You-Go -CurrentStorageAccount <testmachine>
Add-AzureVhd -Destination https://<testmachine>.blob.core.windows.net/vhds/<win2012r2>.vhd -LocalFilePath D:\win2012r2.vhd
Once you run the above cmdlet, it will first calculate MD5 for that VHD file. MD5 hash of your file is to guarantee that your file is transferred correctly. After the MD5 is calculated successfully, a blob of the same size as the disk is allocated in your storage account. It will then start to upload your VHD to Azure.
Note: Uploading the VHD may take time, depending on the Internet connection and the size of the VHD.
Once the VHD is successfully uploaded, you will get the “Succeeded” message in PowerShell. You can then browse the VHD from Azure Storage. Before we can use the VHD as disk, it needs some configuration. We need to provide it some logical name that can be used in subsequent operations.
Step 3: Configuring Disk on Azure Portal
Configuration will allow us to make a disk from VHD from where we can specify that this particular VHD contains an Operating System to use it to create a VM from it. To accomplish this task, go through the following steps:
- Navigate to Azure Portal
- Go to Virtual Machines from the Menu
- Move to “Disks” tab.
- Under Disk tab, click on “Create” button.
- Provide a logical name for the Disk.
- Locate the VHD URL in Azure Blob Storage.
- Select (check) the VHD contains an Operating System checkbox.
- Ensure Windows is selected in Operating Systems family.
- Click the “tick” button to create Azure Disk.
Step 4: Creating VM from Disk on Azure
Now that the disk is created, we shall create a VM using that disk. To create VM from the disk, follow the below steps:
- Click on the Instances tab (on the Virtual Machines section of the Azure Portal)
- Click on “New” button
- Click on “From Gallery”
- On the “Choose an Image” window, click on “My Disks”
- Select the disk that you have created and click Next.
- On the Virtual Machine configuration page, provide the VM name, tier as Standard, select the appropriate size and click Next.
- On the next page, specify either a new cloud service or an existing Cloud Service.
- Specify the Region that contains the VHD and leave the Availability Set option “None”. Leave the default Endpoints configuration & click Next.
- On the third page, Unselect the “VM Agent that supports extensions” is already installed checkbox and click Launch.
After completing above procedure, you can check the status of VM under Virtual Machines tab.
So in this way you can move your Windows Instance from AWS or on premise to Azure and you don’t need to configure it whole again.
I hope the blog enriched you with some good handy information and tactics. Stay tuned for more such blogs on various Cloud platforms.