如何detach/dissociate public ARM VM的IP
How to detach/dissociate public IP of ARM VM
我有一个带有 public IP 的 ARM 虚拟机。我想在测试后 detach/dissociate 这个 public IP。我可以看到有一个使用 azure portal 的选项-
我想使用 azure powershell 做同样的事情。我尝试查找与 public IP 相关的 azure cmdlet,但无法实现。
如果有人能给我一些线索,这是如何做到的?
您需要获取网络接口对象并从中删除 IP 地址 ID,然后将更改推送回 Azure。
$nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla
$nic.IpConfigurations.publicipaddress.id = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic
许多 Azure cmdlet 的工作方式相似。
不确定此 PowerShell 方法是否有效。
空赋值给出错误
PS C:\Users\xxxxxxxxxx> $nic.IpConfigurations.publicipaddress.id=$null
The property 'id' cannot be found on this object. Verify that the property
exists and can be set.
At line:1 char:2
+ $nic.IpConfigurations.publicipaddress.id=$null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
这就是我所做的解决方法。
$nic = Get-AzNetworkInterface -Name $pip.NICName -ResourceGroup `
$pip.ResourceGrou
$count= $nic.IpConfigurations.Name.Count
$i=0
while ($i -le ($count-1)){
$nic.IpConfigurations[$i].publicipaddress.id=$null
$i++}
Set-AzNetworkInterface -NetworkInterface $nic
我有一个带有 public IP 的 ARM 虚拟机。我想在测试后 detach/dissociate 这个 public IP。我可以看到有一个使用 azure portal 的选项-
我想使用 azure powershell 做同样的事情。我尝试查找与 public IP 相关的 azure cmdlet,但无法实现。 如果有人能给我一些线索,这是如何做到的?
您需要获取网络接口对象并从中删除 IP 地址 ID,然后将更改推送回 Azure。
$nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla
$nic.IpConfigurations.publicipaddress.id = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic
许多 Azure cmdlet 的工作方式相似。
不确定此 PowerShell 方法是否有效。
空赋值给出错误
PS C:\Users\xxxxxxxxxx> $nic.IpConfigurations.publicipaddress.id=$null
The property 'id' cannot be found on this object. Verify that the property
exists and can be set.
At line:1 char:2
+ $nic.IpConfigurations.publicipaddress.id=$null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
这就是我所做的解决方法。
$nic = Get-AzNetworkInterface -Name $pip.NICName -ResourceGroup `
$pip.ResourceGrou
$count= $nic.IpConfigurations.Name.Count
$i=0
while ($i -le ($count-1)){
$nic.IpConfigurations[$i].publicipaddress.id=$null
$i++}
Set-AzNetworkInterface -NetworkInterface $nic