Azure Power Shell - 如何更改网络子网 [英] Azure Power Shell - How to change network subnet
问题描述
我正在尝试更改通过 Azure 中的资源管理器部署的现有 VM.VM 配置了错误的虚拟网络/子网.无法通过 portal.azure.net
更改此设置.
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.
我已通过运行:$adapter = Get-AzureRmNetworkInterface -Name xxxxx -ResourceGroupName xxxxx
设法检索了所需的网络适配器.
I've managed to retrieve the required network adapter by running: $adapter = Get-AzureRmNetworkInterface -Name xxxxx -ResourceGroupName xxxxx
.
我可以通过 $adapter.IpConfigurations.Subnet
查看当前配置的子网 ID,并且我通过 $net = Get-AzureRmVirtualNetwork -ResourceGroupName xxxxx -Name 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
.
我尝试更改 $net.IpConfigurations.Subnet.Id = $net.Subnets.Id
但我失败了:
I tried changing the $net.IpConfigurations.Subnet.Id = $net.Subnets.Id
but I get a failure :
资源 xxxx 引用的子网默认值不一样 Virtual网络....
Subnet default referenced by resource xxxx is not the same Virtual Network ....
如果使用资源管理器(经典"具有简单的Set-Subnet
命令).
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).
推荐答案
无法为现有的 ARM 部署 VM 更改虚拟网络.但是,更改 VM 的子网非常容易.
Changing the Virtual Network for an exiting ARM deployed VM is not possible. But, changing the subnet for a VM is quite easy.
- 登录
- 选择您要更改的网络接口,然后点击IP 地址.
- 选择子网并指定 IP 地址,或选择动态分配.
- 如果现有子网均不符合您的要求,请单击您的虚拟网络以创建新子网.
如果你真的想改变你的虚拟机的虚拟网络,你可以备份你的操作系统磁盘,然后用操作系统磁盘创建一个新的虚拟机,当然还有你想要的虚拟网络.
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.
这篇关于Azure Power Shell - 如何更改网络子网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!