How to add security rules to an existing Network Security Group?
Hi all,
I cannot figure out how to add a rule to an NSG that already exists...
I've tried both New-AzureRmNetworkSecurityRuleConfig and Add-AzureRmNetworkSecurityRuleConfig and it appears to create the object with a Provisioning State of null. Then I've tried to Set-AzureRmNetworkSecurityRuleConfig. However the rule never gets added....
Can someone please help me understand this process?
Thank you !
@deepakswifty can you provide some guidance here?
Hi @timmayg,
Add-AzureRmNetworkSecurityRuleConfig and Set-AzureRmNetworkSecurityRuleConfig create in-memory objects. You would have to call Set-AzureRmNetworkSecurityGroup to commit your state to the service. For example.
$nsg = Get-AzureRmNetworkSecurityGroup
$nsg | Add-AzureRmNetworkSecurityRuleConfig
(or) if you want to put them all in one line
Get-AzureRmNetworkSecurityGroup
Thanks, Deepak.
Hi @deepakswifty Thanks very much! This worked perfectly.
So this post was made back in December of 2015 and yet the documentation on this cmdlet still has not been updated with even one example: https://msdn.microsoft.com/en-us/library/mt603772.aspx
Previously reported https://github.com/Azure/azure-powershell/issues/70 Will track from that issue. Thanks.
I wonder what it takes to add complete contextual examples, best practices for each of the PS commands. Or in case of NSG rules - adding a requirement "please run set command after doing everything in memory". Even now https://msdn.microsoft.com/en-us/library/mt603772.aspx is not updated. Can we add the example ?
Is there a way to update an existing NSG with new rules in .JSON format?
+1 to the json question for existing NSG's by @1scscott.