Azure Function + ARM:将应用程序设置与当前设置合并 [英] Azure Function+ARM: merge app settings with current settings

查看:92
本文介绍了Azure Function + ARM:将应用程序设置与当前设置合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的部署分为两个管道

  1. 部署基础结构(运行ARM模板)
  2. 部署和部署配置应用程序(上传应用程序,运行脚本)

我的ARM模板包含一个AppSettings数组,如下所示:

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"

无论何时运行基础架构管道,它都会完全删除所有通过脚本(例如foo)添加的应用设置.有没有一种方法可以告诉ARM将已部署的AppSettings与模板定义的设置合并"?理想情况下,这在第一次部署ARM模板时也应该起作用.

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.

我当前的解决方法是简单地完全删除ARM模板的AppSettings部分.

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

推荐答案

否,您不能具有合并行为.我认为您无法使用Arm模板设置单个应用程序设置值,因此您需要将在部署时添加的那些键放到Arm模板中,或从Arm模板中删除应用程序设置.

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.

这篇关于Azure Function + ARM:将应用程序设置与当前设置合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆