2
votes

My deployment is split into two pipelines

  1. deploy infrastructure (run ARM template)
  2. deploy & configure application (upload app, run script)

My ARM template contains an AppSettings array, like this:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
        // ...
  },
  "variables": {
    "functionAppName": "[parameters('appName')]",
    "storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "type": "Microsoft.Web/sites",
      "name": "[variables('functionAppName')]",
      "location": "[parameters('location')]",
      "kind": "functionapp",
      "dependsOn": [],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
        "siteConfig": {
          "appSettings": [
            {
              "name": "AzureWebJobsStorage",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
              "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
              "name": "WEBSITE_CONTENTSHARE",
              "value": "[toLower(variables('functionAppName'))]"
            },
            {
              "name": "FUNCTIONS_EXTENSION_VERSION",
              "value": "~2"
            },
            {
              "name": "WEBSITE_NODE_DEFAULT_VERSION",
              "value": "6.5.0"
            },
            {
              "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
              "value": "[reference(resourceId('microsoft.insights/components/', parameters('applicationInsightsName')), '2015-05-01').InstrumentationKey]"
            }
          ]
        }
      }
    }
  ]
}

During the application deployment, I set new app settings, like this:

az functionapp config appsettings set --resource-group $resourceGroupName 
   --name $functionAppName --settings "foo=bar"

Whenever the infrastructure pipeline is run, it completely removes all app settings which were added via script (e.g. foo). Is there a way to tell ARM to "merge" the deployed AppSettings with the settings defined by the template? Ideally, this should also work when deploying the ARM template for the very first time.

My current workaround is to simply remove the AppSettings part of the ARM template completely.

1

1 Answers

4
votes

No, you cannot have merge behaviour. I dont think you can set individual app setting values with arm templates, so you'd need to put those keys you add at deployment time to the arm template, or remove appsettings from the arm template.