Reputation: 3
I cannot make it work, please review below code
$nsg = Get-AzureRmNetworkSecurityGroup -Name MYNSG001 -ResourceGroupName MYRG
$nsg | Get-AzureRmNetworkSecurityRuleConfig -Name MYRULE
Set-AzureRmNetworkSecurityRuleConfig -Name MYRULE -NetworkSecurityGroup $nsg -Priority 110
Thanks in advance
Upvotes: 0
Views: 752
Reputation: 42043
There are two points that you missed:
You need to use Set-AzureRmNetworkSecurityGroup
at last.
You need to provide all required security rule parameters, not only Priority
, it is not allowed when using Set-AzureRmNetworkSecurityGroup
.
You could try my sample command below, it works fine on my side.
$nsg = Get-AzureRmNetworkSecurityGroup -Name "NSG name" -ResourceGroupName "<resource group name>"
$nsg | Get-AzureRmNetworkSecurityRuleConfig -Name "Port_8080"
$config = Set-AzureRmNetworkSecurityRuleConfig -Name "Port_8080" -NetworkSecurityGroup $nsg -Priority 110 -Protocol "*" -Access "Allow" -Direction "Inbound" -SourceAddressPrefix "Internet" -SourcePortRange "*" -DestinationAddressPrefix "*" -DestinationPortRange "8080"
$config | Set-AzureRmNetworkSecurityGroup
For more details about the parameters, refer to this link.
Upvotes: 1