I'm trying to change an existing VM deployed via Resource Manager in Azure. The VM is configured with a wrong VirtualNetwork / Subnet. Changing this via portal.azure.net
is not possible.
I've managed to retrieve the required network adapter by running: $adapter = Get-AzureRmNetworkInterface -Name xxxxx -ResourceGroupName xxxxx
.
I can see the current configured subnet id via $adapter.IpConfigurations.Subnet
and I've retrieved the new subnet via $net = Get-AzureRmVirtualNetwork -ResourceGroupName xxxxx -Name xxxxx
.
I tried changing the $net.IpConfigurations.Subnet.Id = $net.Subnets.Id
but I get a failure :
Subnet default referenced by resource xxxx is not the same Virtual Network ....
Can anybody tell me how to change the virtual network that a network adapter is using if it was deployed using Resource Manager (the "Classic" has the simple Set-Subnet
command).