updating NSG Rule via powershell doesnt work

陌路散爱 提交于 2021-01-29 06:31:00

问题


I follow exactly what's on the Microsoft document but with no luck

I'm trying to update the Priority rule from 120 to 4040

set-azurermnetworksecurityruleconfig

code I follow:

$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

回答1:


You are not updating the network security group in Azure, you are only modified your local powershell object. you need to push changes to azure. sample code:

$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


来源:https://stackoverflow.com/questions/53028450/updating-nsg-rule-via-powershell-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!