Today I am going to show you how to move/migrate VM to a different VNET.
First of all, if you suddenly need to move VM to a different VNET it means that you haven’t planned accordingly. Or, it might be that requirements have changed, but VM is already up and running.
Anyway, there is no straight process to move VM to a different virtual network.
In the screenshot below I have a Win2016 VM deployed to Marty-TestVM-vnet virtual network.
VNET is configured to use default address space, which is 10.2.0.0/24. Subnet – default 10.2.0.0/24
What I am going to do is, create Azure Backup and Recovery Services, backup a VM and will restore VM to the VNET with correct IP Address Space and Subnet.
First, click New and type in the search box Backup and click on Backup and Site Recovery (OMS)
Fill up the data. Keep in mind that Recovery Services Vault must be in the same location as items you want to backup. In my case it is UK South.
After Recovery Services Vault is created, we need to add our Azure VM to Backup vault. Simply click on the Recovery Vault instance. We see that Monitoring, Backup and Site Recovery sections do not indicate any activity. We need to add our VM to the Backup list. Click +Backup ans another blade will expand. We choose Azure as the source of the workload and Virtual Machine as the item we want to backup. Click OK
In the second step we have to choose the default policy or create new one. In this case we leave default and click OK
In the last step it will list all the available VMs in that region where our Recovery Services vault is created. Choose the VM(s) you want to backup and click OK. If you need to add any VMs later on, just repeat the same steps and click on the VMs you want to add to your Recovery Services vault.
After you get all 3 steps marked with the green check, click Enable backup.
Now on the Recovery Services vault blade, Overview section you will see that Backup Items has changed to 1.
Because we need backup VM straight away and don’t want till the policy will kick in, we need to initiate it manually. Click on the Backup Items as per image above, click on Azure Virtual Machine instance, VM and click Backup Now.
Now on the Overview section, under the Backup jobs, you will see that there is a job in progress.
Click on it and it will take you to Backup jobs blade where you can check and refresh the progress.
While the VM backup is taking care of, we need to take care of where we want to restore the VM. In this case we need to create a VNET and subnet accordingly.
Go to New, type virtual network and from the market place choose Virtual network. Let’s give it a name and put it under 172.20.9.0/24 address space. Click Create.
Now when backup has been completed we need to restore VM. Click on Backup items, choose Azure Virtual Machine, select a VM you want to restore and click Restore VM.
In the first step, you need to choose the restore point. In this case, we have only one. If there is no special need to restore older snapshot, choose the latest one and click OK.
In step 2 we need to provide the rest of the details. We have to choose VM name, Resource Group where we want to restore it to, choose predefined Virtual Network. We choose AnotherVNET that we have created earlier and Corp-Subnet. Click OK and Restore.
You can check the progress of VM restore in the same Overview blade, under Backup Jobs.
After VM restore has been completed, let’s check VM and network properties.
Now we can decommission our old VM and that is it.