通过powershell更新NSG规则不起作用

通过powershell更新NSG规则不起作用,powershell,Powershell,我完全按照Microsoft文档上的内容操作,但运气不佳 我正在尝试将优先级规则从120更新为4040 我的守则如下: $nsg = Get-AzureRmNetworkSecurityGroup -Name EA-NSG-AAA -ResourceGroupName EA-RG $nsg | Get-AzureRmNetworkSecurityRuleConfig -Name name-02 Set-AzureRmNetworkSecurityRuleConfig -Name name-02

我完全按照Microsoft文档上的内容操作,但运气不佳

我正在尝试将优先级规则从
120
更新为
4040

我的守则如下:

$nsg = Get-AzureRmNetworkSecurityGroup -Name EA-NSG-AAA -ResourceGroupName EA-RG
$nsg | Get-AzureRmNetworkSecurityRuleConfig -Name name-02
Set-AzureRmNetworkSecurityRuleConfig -Name name-02 -NetworkSecurityGroup $nsg -Priority 4040

您没有更新Azure中的网络安全组,您只修改了本地powershell对象。您需要将更改推送到azure。示例代码:

$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName %rg_name% -Name %nsg_name%
Set-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $nsg `
    -Name %rule-name% `
    -Access Allow `
    -Protocol Tcp `
    -Direction Inbound `
    -Priority 777 `
    -SourceAddressPrefix %data% `
    -SourcePortRange * `
    -DestinationAddressPrefix * `
    -DestinationPortRange 3389
$null = Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $nsg