Updating Azure app gateway rewrite rules with ARM template

Occasional Visitor

I've been learning about how ARM templates work and how there is an incremental mode. Can I perform a custom deployment that will update a resource with a template that only includes what I want to update?

 

What I'm trying to accomplish is to update or add rewrite rules for a specific set in our app gateway (see example below).

 

When I try the following I get InvalidTemplateDeployment errors with messages about missing template properties i.e. "0 IP configuration specified for gateway".

 

For my template I was trying to follow an example here https://learn.microsoft.com/en-us/azure/architecture/guide/azure-resource-manager/advanced-templates...

 

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
  ...
  },
  "resources": [
    {
      "apiVersion": "2020-06-01",
      "type": "Microsoft.Resources/deployments",
      "name": "updateRewriteRules",
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.1",
          "resources": [
            {
              "type": "Microsoft.Network/applicationGateways",
              "apiVersion": "2020-05-01",
              "name": "[parameters('applicationGatewayName')]",
              "location": "[parameters('location')]",
              "properties": {
                "rewriteRuleSets": [
                  {
                    "name": "[parameters('rewriteSetName')]",
                    "properties": {
                      "rewriteRules": [
                        {
                          "ruleSequence": 300,
                          "conditions": [],
                          "name": "security-response-headers",
                          "actionSet": {
                            "requestHeaderConfigurations": [],
                            "responseHeaderConfigurations": [
                              {
                                "headerName": "Permissions-Policy",
                                "headerValue": "accelerometers=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          ],
          "outputs": {}
        }
      }
    }
  ],
  "outputs": {}
}

 

0 Replies