gpt4 book ai didi

Azure函数+ARM : merge app settings with current settings

转载 作者:行者123 更新时间:2023-12-02 03:20:04 25 4
gpt4 key购买 nike

我的部署分为两个管道

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

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

{
"$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]"
}
]
}
}
}
]
}

在应用程序部署期间,我设置了新的应用程序设置,如下所示:

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

每当基础设施管道运行时,它都会完全删除通过脚本添加的所有应用设置(例如foo)。有没有办法告诉 ARM 将部署的 AppSettings 与模板定义的设置“合并”?理想情况下,这在第一次部署 ARM 模板时也应该有效。

我当前的解决方法是完全删除 ARM 模板的 AppSettings 部分。

最佳答案

不,你不能有合并行为。我认为您无法使用arm模板设置单独的应用程序设置值,因此您需要将在部署时添加的那些键放入arm模板,或者从arm模板中删除应用程序设置。

关于Azure函数+ARM : merge app settings with current settings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55063731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com