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?

  • Sounds more a question for Server Fault instead... – icelava Oct 8 '14 at 2:16

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.

  • 1
    fyi After deleting my VM I had to wait a couple of minutes and/or CTRL-F5 the management portal before it would recognise the disk being there. Then I could create a VM from the VHD through New > Virtual Machine > From Gallery. – Rory Aug 6 '13 at 12:57
  • 4
    +1 - And while this is a stupid pain in the butt and I don't understand why such a drastic measure is needed, it wasn't so hard or time consuming. – Jason Kleban Nov 29 '13 at 22:35

You should create the Virtual Network first, define the address space, then make sure the VM connected to the Network.

If you already create the VM, delete the VM but keep the disk. Then create the VM using the existing disk in the galery and make sure using the virtual network that you already defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.