Kent
Kent

Reputation: 1

updating NSG Rule via powershell doesnt work

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

Upvotes: 0

Views: 1520

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

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

Upvotes: 1

Related Questions