Azure Virtual Machines – Change the Subnet of a Virtual Machine or Network Interface Card using Azure Portal

In this article, we are going to learn how to change the Subnet of a given Virtual Machine.

While working on setting up the Azure Application Gateway, I had to create three virtual machines in a single Subnet. However, by mistake, I created an Azure Virtual Machine in an incorrect Subnet. Instead of creating the Virtual Machine vm1 in the web-snet subnet, I created it in the other subnet named gateway-snet as shown below.

1-Azure Virtual Network – Diagram – Change the Subnet of a Virtual Machine

Now, I have to move the Virtual Machine from web-snet subnet to gateway-snet. Let’s learn how to do it.

Advertisements

Before, we move further, we first need to understand how a Virtual Machine is integrated with a subnet. To be more specific Virtual Machines are not directly connected with a Subnet. Virtual Machines are connected with Network Interface Card and in turn those NICs are connected to the Subnets. So, technically speaking, it is not possible to change the Subnet of a Virtual Machine as they are really not connected with the Subnet.

So, in order to change the Subnet associated with a Network Interface Card, navigate to the NIC to which the Virtual Machine is connect by clicking on the NIC associated with the Virtual Machine as shown below.

2-Azure Virtual Machine – Change the Subnet of a Virtual Machine – Select NIC

As shown in the steps of the above diagram

  1. Click on the Virtual Machine for which you would like to change the Subnet
  2. Click on the Networking blade
  3. Click on the Network Interface Card
Advertisements

You will be taken to the Network Interface’s Overview blade. Follow through the below indicators now.

3-Azure Virtual Machine – Change the Subnet of a Virtual Machine – Change Subnet
  1. Click on the IP configurations blade
  2. Click the dropdown associated with the Subnet label
  3. The dropdown shows all the available Subnets. Choose the subnet to which you would like to associate the Network Interface Card.
Advertisements

As soon as you change the subnet, you will see the warning message “The virtual machine associated with this network interface will be restarted to utilize the new subnet” as shown below.

4-Azure Virtual Machine – Change the Subnet of a Virtual Machine – Save

If you are sure about the change and are okay with the restart of the associated Virtual Machine of the Network Interface Card then click on Save button as shown in the above screenshot.

That’s it, the Virtual Machine will be restarted and then you can view the updated Network Topology as shown below.

5-Azure Virtual Machine – Change the Subnet of a Virtual Machine – Updated

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s