Step-By-Step: Move a VM to a different Vnet on Azure
On June 3rd, I wrote about moving Virtual machines from one subnet to another in one virtual network. following that I’ve received a ton of feedback. Some of it about how I missed the point of the original question. “what about moving a current VM from one affinity to another affinity, or from one azure network to another? ” Asked Ray though the comments on the original posts.
So, Ray, and everyone… Here is how you move a VM from one Virtual Network to another. We cant’ just move a virtual machine between networks like we did between subnets. What we need to do is identify the disk used by the VM, delete the VM itself while retaining the disk, and recreate the VM in the target virtual network and attach the original disk to it.
Identify the disk used by a Virtual Machine
1- Log into the Azure portal.
2- In the virtual machines section of the Portal. select the instance/VM that you want to move,
3- In the Dashboard pane for the virtual machine you want to move, scroll down to the disk section and note the disk/disks that your VM has attached to itself.
In my case the disk attached to the vm-test-01 virtual machine. is “VM-Test-01-VM-Test-01-0-201406140351230909”
Delete the existing Virtual Machine
4- while the virtual machine is still selected in the portal, select Delete in the action bar at the bottom of the screen. ensure that you select “Keep the attached disks”
5- Once Deleted, switch your focus in the portal to the Virtual Machines section and the Disk Pane and keep refreshing the screen until the field “Attached to” goes blank.
Create the new Virtual Machine
6- Once the disk reports that it’s not attached to anything. it will also show up the “My Disks” portion of the gallery. let’s create a new VM using that disk. by selecting in the Action bar. New, Compute, Virtual Machine, From Gallery.
7- In the Gallery, select “My Disks” and select the disk that corresponds to the disk that was originally attached to the virtual machine we deleted. in my case “VM-Test-01-VM-Test-01-0-201406140351230909”
8- Fill out the wizard with the name, tier, size … until you get to the Cloud Service. Once you get there you must create a new Cloud Service and select the new virtual Network and subnet you want has the new target for your new VM. You Need a new cloud service because the Cloud Service is a boundary for a variety of settings such as:
- Public IP Address space
- Public DNS Name
- Internet Firewall
- Load Balancing
so switching the network will of course change the IP address space. Once you’ve selected the new Cloud Service, pick the Virtual Network and the subnet you want. And complete the wizard to create the new VM.
once the machine is created you can validate the network by looking at the configuration of the VM.
There you go Ray.
you now know how to move a VM to another virtual Network.
I hope this helps. let me know if ther is anything else I should look into.