Relocating Azure VM to Different Virtual Network

Relocating Azure VM to Different Virtual Network

Introduction

Some time ago I was tasked with moving a few virtual machines, one SQL & one application server to a different Virtual Network (VNET). At first I thought this would be a pretty simple task, and it kind of is - but not as straight forward as it perhaps should be.

I learned that in order for you to be able to relocate a virtual machine from one VNET to another you need to delete it, and re-create it using the same OS-disk. In this post I will show you how I did it..

Document important information & delete the VM

First we need to document some important information. For example one of the virtual machines I was handling was an SQL with several data disks and it is important that they are added back to the new VM in the correct order, with the correct corresponding LUN.

In my case I took some screenshots of the following tabs in the Azure Portal.

Important here not to check any of the "Delete with VM" checkboxes, at least not for the disks.

Pro tip: I will save the OS-disk name to my clipboard so I can easily paste it in the search-bar to find my disk in the portal and be sure to avoid choosing the wrong OS-disk.

Once you are ready you can hit Delete

Create a new VM using the OS-disk

Browse to the disk and select Create VM

From here it is a pretty straight forward process of entering all the correct information to create a new virtual machine. Be sure to check that the size is correct, for the disk-part you can chose to Attach existing disks to re-attach the data-disks you had before.

All the content on the datadisks are still on there and will be available once you have provisioned the virtual machine.

Under Networking you obviously chose the new VNET & Subnet to place your VM in.

Login and verify disks & content

It is a good idea to login to the VM, check data-disks, make sure the content is still there & that everything looks good. That is it, hopefully Microsoft can come up with a better way of doing this but for now this is the process we have.

You're finished!

About the author

About me
If you have landed on my page you will have already understood my passion for tech, but obviously there is more to life than that. Here I will try and outline a few of my other hobbies. Strength training I am a person who loves to move around and challenge