I have a VM with 3 NICs that was deployed from the Marketplace. I need to change the subnets and IP addresses that are currently assigned to NICs 2 & 3 I have tried using PowerShell scripts but receive this error: Set-AzureRmNetworkInterface : Cannot change subnet of network interface /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx 4999/resourceGroups/vcfrg/providers/Microsoft.Network/networkInterfaces/vm200-eth1 while it is in use as a secondary network interface.

Thanks, Scott

  • What happens if you try and do it through the portal? You should be able to go to the NIC object, then IP Address, and then set the subnet – Sam Cogan Jan 6 '17 at 22:12

I had create a VM with two NICs, NIC01( and NIC02(, then I use powershell to set the azure network interface, here is my script, after the script complete, the NIC01 change to It works for me.

$NICname = nic01
$RGname = jason
$NIC = Get-AzureRmNetworkInterface -Name $NICname -ResourceGroupName $RGname
$VNET = Get-AzureRmVirtualNetwork -Name $VNETname  -ResourceGroupName $RGname
$Subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNET -Name subnet03
$NIC.IpConfigurations[0].Subnet.Id = $Subnet2.Id
Set-AzureRmNetworkInterface -NetworkInterface $NIC

enter image description here

And here is the result: enter image description here

  • @Scott Here a good article about how to change Subnet and Virtual Network for Azure Virtual Machines (ASM & ARM), refer to the link:blogs.msdn.microsoft.com/igorpag/2016/03/13/… – Jason Ye Jan 10 '17 at 6:32
  • @Scott Just checking in to see if the information provided was helpful. Please let me know if you would like further assistance. – Jason Ye Jan 13 '17 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.