Step-by-step: Move an Azure IaaS VM between different Azure Subscriptions
11:22 am in Azure, Azure subscription, Cloud, IaaS, Microsoft Azure Storage Explorer, Public Cloud by Wim Matthyssen
From time to time, customers ask me to migrate Azure IaaS virtual machines (VMs) between Azure Subscriptions (for example moving a VM between the Dev subscription and the Prod subscription). There are several ways to accomplish this move, you can use Azure PowerShell or Azure Site Recovery (ASR), but mostly I do it the way that I will describe below.
1) First of all, you need to download an Azure Storage Explorer which enables you to move the VHD (page blob) which is used by the IaaS VM from one storage account (Azure Subscription 1) to another (Azure Subscription 2). Mostly I use the Microsoft Azure Storage Explorer which you can download for free via following link: http://storageexplorer.com/
2) When downloaded and installed you’ll need to add the two Azure Blob Storage Accounts, the one you want to move the VHD from and the one you want to move the VHD to. Open up the Microsoft Azure Storage Explorer, right click Storage Accounts and select Connect to Azure storage…
3) To find the Storage Account name and the Account key, just logon to the Classic Azure portal (https://manage.windowsazure.com/). Go to STORAGE select the correct Storage Account and click MANAGE ACCESS KEYS.
4) Fill in the correct Account name (STORAGE ACCOUNT NAME) and the Account key (PRIMARY ACCESS KEY)
5) Repeat steps 3 to 5 also for the Storage Account in the other Azure Subscription. At the end two Storage Accounts should be available to use in the Microsoft Azure Storage Explorer
6) Now stop the VM (logon trough RDP and choose shutdown) and you are good to copy/paste your VM’s VHD from one Storage Account to another
7) Open up Microsoft Azure Storage Explorer, right click the VHD for the VM you just stopped and select Copy
8) Open the other Storage Account’s Blob container (in my example azureos01 – Blob Containers – vhds) and select Paste. Be aware that this copy can take some time depending on the size of the VHD
9) When the VHD is completely copied, open the Azure classic portal and logon to the second Azure Subscription. Go to VIRTUAL MACHINES, then DISKS and select CREATE A DISK
10) Fill in a NAME (for example AZ-VM-SUB2) and select the correct VHD URL from the storage you just moved your VHD file to. Mark “The VHD contains an operating system.” and select Windows. Click the check mark to finish
11) As the next step create a new VM. Click NEW – COMPUTE – VIRTUAL MACHINE – FROM GALLERY
12) Select MY DISKS and select the newly created disk (in my example AZ-VM-SUB2)
13) In the next screen choose a proper VIRTUAL MACHINE NAME, the TIER and the VM SIZE
14) Create a new CLOUD SERVICE or select an existing one, choose the correct VNET and SUBNET. If an AVAILIBILITY SET is required, select or create it
15) Select the ENDPOINTS you require and finally press the check mark icon to start provisioning the VM
16) Like you can see the VM is created and starts Running. You should now able to connect to it again with RDP
17) If the VM looks and reacts like it should, you can delete the original VM with the attached VHD in the first Azure Subscription. Also don’t forget to delete the Cloud Service
This concludes this blog post, hope it helps!
Wim Matthyssen (@wmatthyssen)
Recent Comments