[英]Azure Power Shell - How to change network subnet
I'm trying to change an existing VM deployed via Resource Manager in Azure. 我正在尝试更改通过Azure中的资源管理器部署的现有VM。 The VM is configured with a wrong VirtualNetwork / Subnet.
虚拟机配置了错误的虚拟网络/子网。 Changing this via
portal.azure.net
is not possible. 无法通过
portal.azure.net
更改此portal.azure.net
。
I've managed to retrieve the required network adapter by running: $adapter = Get-AzureRmNetworkInterface -Name xxxxx -ResourceGroupName xxxxx
. 我已经设法通过运行以下命令来检索所需的网络适配器:
$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
. 我可以通过
$adapter.IpConfigurations.Subnet
查看当前配置的子网ID,并且已经通过$net = Get-AzureRmVirtualNetwork -ResourceGroupName xxxxx -Name xxxxx
检索了新的子网。
I tried changing the $net.IpConfigurations.Subnet.Id = $net.Subnets.Id
but I get a failure : 我尝试更改
$net.IpConfigurations.Subnet.Id = $net.Subnets.Id
但失败了:
Subnet default referenced by resource xxxx is not the same Virtual Network ....
资源xxxx引用的子网默认不是同一虚拟网络....
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). 如果使用资源管理器 (“经典”具有简单的
Set-Subnet
命令)进行部署,谁能告诉我如何更改网络适配器使用的虚拟网络。
Changing the Virtual Network for an exiting ARM deployed VM is not possible. 无法为现有的ARM部署的VM更改虚拟网络。 But, changing the subnet for a VM is quite easy.
但是,更改VM的子网非常容易。
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. 如果您确实要更改VM的虚拟网络,则可以备份OS磁盘,并使用OS磁盘(当然还有所需的虚拟网络)创建新的VM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.