title: Azure Function+ARM: merge app settings with current settings
body: <p>My deployment is split into two pipelines</p>
  
  <ol>
  <li>deploy infrastructure (run ARM template)</li>
  <li>deploy &amp; configure application (upload app, run script)</li>
  </ol>
  
  <p>My ARM template contains an AppSettings array, like this:</p>
  
  <pre><code>{
    "$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]"
              }
            ]
          }
        }
      }
    ]
  }
  </code></pre>
  
  <p>During the application deployment, I set new app settings, like this:</p>
  
  <pre><code>az functionapp config appsettings set --resource-group $resourceGroupName 
     --name $functionAppName --settings "foo=bar"
  </code></pre>
  
  <p>Whenever the infrastructure pipeline is run, it completely <strong>removes</strong> all app settings which were added via script (e.g. <code>foo</code>). 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.</p>
  
  <p>My current workaround is to simply remove the AppSettings part of the ARM template completely.</p>