concat NSG rules #5883
-
I've troubles in deploying NSG rules. The idea is to have a set of default rules and another set of individual rules per NSG. So, for now I tried: Default rules Example Individual rules Example In my bicep file I want to create the NSG and try to match the NSG-name specified in
I've tried different things - but nothing worked so far... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There is a sample here, that uses a lookup table and also union that allows two, or more sets of nsg rules to be merged. Some are defaults in the same file, others may come from parameters etc. https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/NSG.bicep#L291 Both of these are optional i.e. default rules or from the param file or other place. var NSGInfo = [for (subnet, index) in subnetInfo: {
match: ((Global.CN == '.') || contains(Global.CN, subnet.name))
subnetNSGParam: contains(subnet, 'securityRules') ? subnet.securityRules : []
subnetNSGDefault: contains(NSGDefault, subnet.name) ? NSGDefault[subnet.name] : []
}] Essentially if they exist they are used, if not an empty array is created, which is ignored as part of the union(). You can extend that loop above to as many different places or sets of rules that you want to combine. |
Beta Was this translation helpful? Give feedback.
There is a sample here, that uses a lookup table and also union that allows two, or more sets of nsg rules to be merged.
Some are defaults in the same file, others may come from parameters etc.
https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/NSG.bicep#L291
Both of these are optional i.e. default rules or from the param file or other place.
Essentially if they exist they are used, …