Moving An Azure VM To Different Virtual Network

It’s a simple enough operation (PowerShell) to move a virtual machine to a different subnet within a virtual network. But what if you want to move the virtual machine to a different virtual network? That’s a bit more complex to do because you cannot just lift the VM to another network.

Instead you will have to:

1: Delete the virtual machine, choosing to keep the attached disks. Doesn’t Azure Backup of Azure Virtual Machines sound like a good idea right now? Go do that first Smile

image

2: Create a new virtual machine from the existing disks. The above deletion process keeps the original disks, and deletes the meta data of the VM. You are now going to create new meta data using the remaining disks. This is like moving the hard drives from one broken server to a replacement server. Go into the wizard and instead of selecting a template, choose your old disk. Make sure you know which one it is first – the name of the old VM (FS1 in this case) is usually in the file name.

image

3: Complete the wizard and select the new virtual network. If this is a new network/application then you probably will have to create a new cloud service too.

4: Attach any data disks. If the old VM had any data disks then they’ll need to be reattached. Shutdown the VM and attach the disks.

image

Technorati Tags:

5 thoughts on “Moving An Azure VM To Different Virtual Network”

  1. We went through this recently when trying to add a new network to our VM’s. I really hope with vnext that we see the ability to do this on the fly with Azure.

  2. I’ve been trying to automate this process. I have two locations each with Vnet and VPN. Both using ASR. If Physical Site 1 is down, due to hurricane, how can I failover/move all the VMs in Site1 VNet to Site2 Vnet. I don’t have multisite routing. Is this the only solution? In ASR there are scripts that can be run. I want the script to set the VNet of my choosing.

  3. Aidan, It seems that the interface has changed in the Preview Portal and I don’t see a way to preserve the default boot (C) drive disk when deleting the old VM.

    1. I haven’t noticed that, but I really only go into the preview to do anything I cannot do in the production portal. And to be brutally honest, most of my time is spent working in ASR which is only in the production portal.

Leave a Reply to AFinn Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.