4

Can someone let me know how to move a VM from one Virtual Network to another. In the image, I would like to move the VM webtestnic-backend-.... from Virtual network 'webtestvnet-arrmb7u3eu35o to my VirtualNetork.

azure

Can you let me know how to do that?

Cheers

Carlton

Carltonp
  • 171
  • 1
  • 3
  • 8

3 Answers3

5

Moving VMs between different VNET is not supported. To move the VM to another VNET, the only solution for now is re-create the VM with the same vhd file.

To redeploy the VM with same vhd file, please try this template.

BTW, we are able to move the VMs between the subnets in the same VNET. It contains 3 steps:

  1. Get the VM (NIC) configuration
  2. Edit the VM (NIC) configuration
  3. Update the edited configuration

Here is a good step-by-step guide:

How to change Subnet and Virtual Network for Azure Virtual Machines (ASM & ARM)

1

Although an old post now I'd like to list another solution I found recently when trying to figure out the same thing. It is possible to do this and automate the entire process using PowerShell. I found this excellent blog post which shows how to do it. Hope it helps!

https://think-like-a-computer.com/2020/02/06/azure-move-vm-to-another-vnet-powershell/

Mucker
  • 382
  • 2
  • 10
  • The link is dead. Thanks to the one who captured the web. This is the link to wayback machine https://web.archive.org/web/20200207051825/https://think-like-a-computer.com/2020/02/06/azure-move-vm-to-another-vnet-powershell/ – Oki Erie Rinaldi Aug 27 '20 at 10:48
  • I ran this script and my VM disappeared :( – Tim Davis Sep 06 '20 at 19:35
1

You can't move a VM to another Virtual Network without redeploying.

To redeploy a VM, I like this method, but here's Microsoft guide using Powershell. Just make sure to change the associated network interface for one within desired VNet.

Bruno Faria
  • 3,814
  • 1
  • 13
  • 18
  • Hi Bruno, thanks for responding. Looking at your powershell scripts, it doesn't appear to assigning the interface to a virtual network. However, it does assign the interface to a resource group. Don't I need to assign the interface to both the Resource group as well as the virtual network? – Carltonp Nov 10 '16 at 18:14
  • I removed the cmdlets because I made a double check and realized you really can't move the VM to another Virtual Network without redeploy. You can change a NIC that is using a different configuration, but it still need to be in the same VNet. I used pipe in those cmdlets to avoid retyping some of the parameters like vm name. – Bruno Faria Nov 10 '16 at 18:18