【问题标题】:Deploying Azure Firewall IP Group changes fails with conflict部署 Azure 防火墙 IP 组更改失败并出现冲突
【发布时间】:2021-09-24 17:53:39
【问题描述】:

我正在尝试使用策略、规则和一组 IPGroup 部署 Azure 防火墙。当我部署 ARM 模板以开始一切正常时。稍后如果我想更改其中一个 IPGroup 中的某些内容,并尝试部署该 IPGroup 更改,Azure 部署将失败并显示状态:与消息冲突:

{
    "status": "Failed",
    "error": {
        "code": "ResourceDeploymentFailure",
        "message": "The resource operation completed with terminal provisioning state 'Failed'."
    }
}

我尝试在它们自己的 ARM 模板中清楚地管理 IPGroups,并将它们放在带有 DependsOn 的 Azure Policy Rule Collection ARM 模板中,看看将它们全部部署在一起是否会有所帮助,但无论哪种方式,我们都会得到“冲突”.. 我想我想知道更新作为防火墙网络规则一部分的 IPGroup 的适当方法是什么?如果我不能简单地更新 IPGroup?

这是我的完整 ARM 模板的示例,用于我的 IPGroups 策略。

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "firewallPolicyName": {
            "defaultValue": "[concat('onelucki-fw-parent-policy', uniqueString(resourceGroup().id))]",
            "type": "String"
        },
        "DevSubnets": {
            "defaultValue": "DevSubnets",
            "type": "String"
        },
        "AzureSubnets": {
            "defaultValue": "AzureSubnets",
            "type": "String"
        }
    },
    "variables": {
        "fwPolicyName": "[parameters('firewallPolicyName')]"
    },
    "resources": [
          {
            "type": "Microsoft.Network/ipGroups",
            "apiVersion": "2020-05-01",
            "name": "AzureSubnets",
            "location": "centralus",
            "tags": { "Zone": "MixedZones" },
            "properties": {
                "ipAddresses": [
                    "10.99.1.1"
                ]
            }
        },
        {
            "type": "Microsoft.Network/ipGroups",
            "apiVersion": "2020-05-01",
            "name": "DevSubnets",
            "location": "centralus",
            "tags": { "Zone": "Dev" },
            "properties": {
                "ipAddresses": [
                    "10.99.2.2"
                ]
            }
        },
        {
            "type": "Microsoft.Network/firewallPolicies",
            "apiVersion": "2020-11-01",
            "name": "[parameters('firewallPolicyName')]",
            "location": "centralus",
            "properties": {
                "sku": {
                    "tier": "Standard"
                },
                "threatIntelMode": "Alert"
            }
        },
        {
            "type": "Microsoft.Network/firewallPolicies/ruleCollectionGroups",
            "apiVersion": "2020-11-01",
            "name": "[concat(parameters('firewallPolicyName'), '/DefaultNetworkRuleCollectionGroup')]",
            "location": "westus",
            "dependsOn": [
                "[resourceId('Microsoft.Network/ipGroups', parameters('AzureSubnets'))]",
                "[resourceId('Microsoft.Network/ipGroups', parameters('DevSubnets'))]",
                "[resourceId('Microsoft.Network/firewallPolicies', parameters('firewallPolicyName'))]"
            ],
            "properties": {
                "priority": 200,
                "ruleCollections": [
                    {
                        "ruleCollectionType": "FirewallPolicyFilterRuleCollection",
                        "action": {
                            "type": "Allow"
                        },
                        "rules": [
                            {
                                "ruleType": "NetworkRule",
                                "name": "DemoRule",
                                "ipProtocols": [
                                    "TCP"
                                ],
                                "sourceAddresses": [],
                                "sourceIpGroups": [
                                    "/subscriptions/<subscriptionIDHere>/resourceGroups/onelucki-fw/providers/Microsoft.Network/ipGroups/DevSubnets"
                                ],
                                "destinationAddresses": [],
                                "destinationIpGroups": [
                                     "/subscriptions/<subscriptionIDHere>/resourceGroups/onelucki-fw/providers/Microsoft.Network/ipGroups/AzureSubnets"
                                ],
                                "destinationFqdns": [],
                                "destinationPorts": [
                                    "135",
                                    "445"
                                ]
                            }
                        ],
                        "name": "DemoDeployRuleCollection",
                        "priority": 1300
                    }
                ]
            }
        }
    ]
}

【问题讨论】:

    标签: azure firewall arm-template azure-template


    【解决方案1】:

    需要一次部署一个 IP 组。此外,防火墙策略需要依赖于正在使用的 IP 组,尽管它没有列出它们。

    IP 组的部署似乎在部署期间对防火墙策略进行了一些验证/更新。

    【讨论】:

    • 我正在尝试单独部署 IP 组,因为这将有助于我们更轻松地管理它们。他们这样做时会失败。尝试在策略模板中添加“DependsOn”实际上是我首先要做的事情之一。但是当 IPGroups 未在 ARM 模板中列出但在 DependsOn 中标识时,ARM 模板会失败,因为它们不是在那里定义。我目前正在尝试编写 Powershell 来解决这个问题,因为当我无法通过 arm 模板更新时,我似乎可以通过 Powershell 更新 IPGroup
    • 是的。前几天我遇到了一个问题,尽管没有任何更改,但它不会在模板中部署 IP 组。测试部署也有效,产品部署失败。必须删除策略中引用 IP 组的规则才能部署。似乎链接到两个策略的 IP 组可能会导致问题。考虑自己将 PowerShell 用于 IP 组。
    • 是的,我的 Powershell 更新过程目前已成功运行。无论防火墙策略规则中是否引用了 IPGroup,我都可以更新 IPGroups 上的 IP 地址和标签等内容。我已经能够在我们的“测试”防火墙设置中成功更新 IPGroup,但还没有将更改推送到生产,有一个关于以这种方式更改 IPGroups 的问题实际上更新了防火墙和规则的行为例如,基于 IPGroup 中的新 IP 地址,很快就会尝试这样做
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    相关资源
    最近更新 更多