Is it possible to add an existing Azure VM to an Azure Virtual Network?

Didn't think this was directly related to programming, so thought Superuser would be better than Stack Overflow....

Is it possible to add an existing Azure VM to an Azure Virtual Network if you didn't add it to the virtual network at the time of creation?

I can't see an option to change which Virtual Network the VM is connected to. Do you just have to do it at the time you create the VM, and if you don't do it then you will need to re-create the VM and delete the existing one?

Example of the scenario:

  • No VM's or Virtual Networks exist
  • I create a VM (VM1), there is no virtual network so it isn't added to one
  • Later I create a Virtual Network in Azure (Network1)

It is possible to create another VM (VM2) and connect it to the Virtual Network (Network1), but can I connect VM1 to Network1 or must I delete VM1 and re-create it to get it connected to Network1?


Solution 1:

You can remove the existing VM and create a new VM with that same VHD, deploying it to the virtual network. But there is no method to move it into the virtual network once the VM is created.

When you remove an existing VM, the VHD for it remains and is registered as a disk in the portal. So when you create a new one you can just select that disk under My Disks in the portal to reuse it.