Last week I was tasked to Copy the Azure VM to another region.
Why to copy Azure VM to a new region ?
- Low cost compared to other location.
- Region near to majority of your users and visitors
Steps to copy Azure VM to another location.
Step 1- The first thing we should do is take a backup before experimenting with the VM.
Step 2- Generalizing the Azure VM
Login to your Azure VM.
Go to C:\Windows\system32\sysprep\ and open the sysprep.exe
Select the Settings as shown above and click on OK.
It will take few minutes to finish.
Step 3- Login to your Azure Powershell and stop the Generalized VM using below command
Login-AzureRmAccount
Stop-AzureRmVM -ResourceGroupName <resourceGroup> -Name <vmName>
For Azure VM with Un-Managed Disk, go to the Storage Account and copy the name of the VHD of the VM as shown below-
Step 4 - Now create a new Resource Group to the destination region where you want to copy the Azure VM.
Step 5- Create a Storage Account in the Resource Group created in Step 4 and then create a Container inside BLOB Storage.
Step 6- Download AzCopy from here http://aka.ms/downloadazcopy and Install it .
Step 7- Navigate to C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy using the Powershell to Run the AzCopy command.
Step 8 - Run the below command to copy the VHD from source to Destination
AzCopy /Source:https://shuidisks446.blob.core.windows.net/vhds /Dest:https://shuidiag102.blob.core.windows.net/vhds /SourceKey:sGqtdFHQWQWYyf2tRWGF5jkeAEubTp13AVaeTM25QogxXE+K0Ezq1ulcs18qGVPhCEp6ULdLLbKVa7fMbUvYZg== /DestKey:iCjeS+eegjkSJXHjH2UqCkqXnUPiCGvxaOG0Ad2LoPgUnvBoWl9wQJtC1jc//lOj4CF7khpLQe791P4QeyTY6Q== /Pattern:shui20161222141315.vhd
/Source: URL of the Source Storage Container
/SourceKey: Access Key of the Source Storage Account
/Dest: URL of the Destination Storage Container
/DestKey: Access Key of the Destination Storage Account
/Pattern: Name of the VHD to be copied
/Pattern: Name of the VHD to be copied
Note: For copying 127 GB VHD from source to destination Storage Account it took around 30 minutes for me.
Step 9: Now that the VHD has been copied to the destination Storage Account, create an Image of that VHD from the Azure Portal and then create an Azure VM of the same.
Comments
Post a Comment