通过 ARM模板部署 Azure功能应用和 AppSettings 时,是否可以告知Azure不要删除 AppSettings 未在模板中声明?
例如,从模板中获取以下 AppSettings 配置,并想象我正在更新现有的功能应用。在这种情况下,将删除名为 storageaccountname_STORAGE 的 AppSetting ,这是不合需要的,因为(例如)它已被创建以便于绑定。
{
"apiVersion":"2016-08-01",
"name":"appsettings",
"type":"config",
"dependsOn":[
"[resourceId('Microsoft.Web/Sites/Slots', variables('functionAppName'), 'Staging')]"
],
"properties":{
"AzureWebJobsStorage":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"AzureWebJobsDashboard":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"APPINSIGHTS_INSTRUMENTATIONKEY":"[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').InstrumentationKey]",
"FUNCTION_APP_EDIT_MODE":"readwrite",
"FUNCTIONS_EXTENSION_VERSION":"~1",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"WEBSITE_CONTENTSHARE":"[toLower(variables('functionAppName'))]",
"WEBSITE_NODE_DEFAULT_VERSION":"6.5.0"
}
}
有没有办法通过 ARM模板选择性地设置 AppSettings ,或者模板根本不适合这种情况所需的功能?
答案 0 :(得分:3)
我前一段时间遇到过这个问题,并且没有在ARM模板中找到解决方案。
在我的情况下,我通过使用在ARM模板之后运行的PowerShell脚本来解决它。 也许你可以使用这个的一些部分:
https://gist.github.com/kirkone/2b5996a57a5610a8a41e2bfd1edc37f1
主要部分是获取当前值,添加或覆盖新值并写回完整列表 此脚本用于VSTS / TFS,但它应该为您提供有关如何完成此操作的提示。
很抱歉没有更好的解决方案,但我希望这也有帮助。
CU
KIRK