Subnet change of VM is only possible if the both subnet are in the same vnet.  Virtual network change of an existing VM is not possible at this moment. Need to delete the VM and create it again. We used old AzureRM Network powershell commands. Refer this article for how to change subnet for azure VM using AzureRM.Network commands.

I have followed below steps to achieve the subnet change for an existing NIC card attached to an VM.

Copy to Clipboard

Get the VM

Copy to Clipboard

One important point is VM should be created in Availability Set with reference  $VM1.AvailabilitySetReference

Now Obtain NIC, subnet and VNET references

Copy to Clipboard

Now, the subnet setting you need to change resides in the “IPConfigurations” property array, you can access it with index [0] and change directly the “Subnet.Id” value to the ID of the new target subnet.

Copy to Clipboard

This concludes how to change subnet of existing Azure VM Nic card using old AzureRM Network powershell commands. Refer only if you still maintain old AzureRM module. Leave your thoughts at the comment box available below.