How to change an Azure VM Subnet

December 2, 2015 at 8:22 am in Azure, Microsoft by Florent


Yestarday I created a SQL VM on Azure. I completed the installation and so on, but after, I saw that the VM was not in the good subnet in my network.

I searched on Internet how to change the subnet and I found this documentation.

So, I will explain to you how to do this with PowerShell (this is the only possibility to do this). As you can see, I have the IP address


My two subnet in my network are the following:


As you can see, the VM is actually in the FrontEnd subnet and I would like to move it in the BackEnd subnet. To do this, execute the following PowerShell command:

Get-AzureVM -Name sql-001 -ServiceName Demo | Set-AzureSubnet -SubnetNames BackEnd | Update-AzureVM


The VM will restart after the execution of the Update-AzureVM cmdlet. When it’s done, go back to your Azure VM interface. You can see that the new IP is in my BackEnd range:


Don’t forget to change the IP in your DNS too if you don’t allow DNS Dynamic Updates. In my VM, I have the following IP: