Azure 如何分离/分离ARM虚拟机的公共IP

Azure 如何分离/分离ARM虚拟机的公共IP,azure,azure-virtual-machine,azure-powershell,Azure,Azure Virtual Machine,Azure Powershell,我有一个带有公共IP的ARM虚拟机。我想在测试后分离/分离此公共IP。我可以看到有一个使用azure portal的选项- 我想用azure powershell做同样的事情。我尝试查找与公共IP相关的azure cmdlet,但未能实现。 如果有人能给我一些线索如何做到这一点?您需要获取网络接口对象,并从中删除Ip地址Id,然后将更改推回Azure $nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla $nic.

我有一个带有公共IP的ARM虚拟机。我想在测试后分离/分离此公共IP。我可以看到有一个使用azure portal的选项-

我想用azure powershell做同样的事情。我尝试查找与公共IP相关的azure cmdlet,但未能实现。
如果有人能给我一些线索如何做到这一点?

您需要获取网络接口对象,并从中删除Ip地址Id,然后将更改推回Azure

$nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla
$nic.IpConfigurations.publicipaddress.id = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic

许多Azure cmdlet的工作方式类似。

您需要获取网络接口对象并从中删除Ip地址Id,然后将更改推回到Azure

$nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla
$nic.IpConfigurations.publicipaddress.id = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic

许多Azure cmdlet以类似的方式工作。

不确定此PowerShell方法是否有效

null赋值给出了错误

 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

不确定此PowerShell方法是否有效

null赋值给出了错误

 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

我要试试我要试试