Public/Deploy/IaaS/networking/firewall/New-CmAzIaasFirewallPolicies.json

{
    "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "FirewallPolicies": {
            "type": "Array"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Resources/Deployments",
            "apiVersion": "2019-10-01",
            "name": "[parameters('FirewallPolicies')[copyIndex('FirewallPoliciesCopy')].templateName]",
            "resourceGroup": "[parameters('FirewallPolicies')[copyIndex('FirewallPoliciesCopy')].resourceGroupName]",
            "copy": {
                "name": "FirewallPoliciesCopy",
                "count": "[length(parameters('FirewallPolicies'))]"
            },
            "properties": {
                "mode": "Incremental",
                "expressionEvaluationOptions": {
                    "scope": "Inner"
                },
                "parameters": {
                    "FirewallPolicy": {
                        "value": "[parameters('FirewallPolicies')[copyIndex('FirewallPoliciesCopy')]]"
                    }
                },
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "FirewallPolicy": {
                            "type": "Object"
                        }
                    },
                    "resources": [
                        {
                            "apiVersion": "2020-11-01",
                            "type": "Microsoft.Network/firewallPolicies",
                            "name": "[parameters('FirewallPolicy').name]",
                            "location": "[parameters('FirewallPolicy').location]",
                            "tags": {
                                "cm-service": "[parameters('FirewallPolicy').service.publish.firewallPolicy]"
                            },
                            "properties": {
                                "sku": {
                                    "tier": "[parameters('FirewallPolicy').sku]"
                                },
                                "threatIntelMode": "[parameters('FirewallPolicy').threatIntelMode]",
                                "threatIntelWhitelist": "[parameters('FirewallPolicy').threatIntelWhitelist]",
                                "basePolicy": "[parameters('FirewallPolicy').basePolicy]",
                                "dnsSettings": "[parameters('FirewallPolicy').dnsSettings]"
                            }
                        },
                        { "condition": "[not(equals(parameters('FirewallPolicy').ruleCollectionGroups[0].name, 'none'))]",
                            "type": "Microsoft.Network/firewallPolicies/ruleCollectionGroups",
                            "apiVersion": "2020-11-01",
                            "name": "[concat(parameters('FirewallPolicy').name, '/', parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].name)]",
                            "location": "uksouth",
                            "dependsOn": [
                                "[resourceId('Microsoft.Network/firewallPolicies', parameters('FirewallPolicy').name)]"
                            ],
                            "copy": {
                                "count": "[length(parameters('FirewallPolicy').ruleCollectionGroups)]",
                                "name": "RuleCollectionGroupsCopy"
                            },
                            "properties": {
                                "priority": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].priority]",
                                "copy": [
                                    {
                                        "name": "ruleCollections",
                                        "count": "[length(parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections)]",
                                        "input": {
                                                "ruleCollectionType": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections[copyIndex('ruleCollections')].ruleCollectionType]",
                                                "action": {
                                                    "type": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections[copyIndex('ruleCollections')].actionType]"
                                                },
                                                "rules": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections[copyIndex('ruleCollections')].rules]",
                                                "name": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections[copyIndex('ruleCollections')].name]",
                                                "priority": "[parameters('FirewallPolicy').ruleCollectionGroups[copyIndex('RuleCollectionGroupsCopy')].ruleCollections[copyIndex('ruleCollections')].priority]"
                                            }
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        }
    ]
}