Reputation: 1404
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).
Upvotes: 2
Views: 5107
Reputation: 2267
Changing the Virtual Network for an exiting ARM deployed VM is not possible. But, changing the subnet for a VM is quite easy.
If you really want to change the Virtual Network of your VM, you can backup your OS Disk, and create a new VM with the OS Disk, and of course with the desired Virtual Network.
Upvotes: 8