不要删除未在模板中声明的AppSettings [英] Don't delete AppSettings not declared in a template
问题描述
通过 ARM模板部署 Azure Function应用和 AppSettings 时,是否可以告诉Azure不要删除 AppSettings未在模板中声明?
When deploying an Azure Function App and AppSettings via an ARM Template, is it possible to tell Azure not to delete AppSettings that are not declared in the template?
例如,从模板中获取以下 AppSettings 配置,并想象我正在更新现有的 Function App .在这种情况下,名为 storageaccountname_STORAGE 的 AppSetting 将被删除,这是不希望的,因为(例如)已创建该应用程序来促进绑定.
For example, take the following AppSettings config from the template and imagine that I'm updating an existing Function App. In this case, an AppSetting called storageaccountname_STORAGE would be deleted, which is undesirable as (for example) it has been created to facilitate a binding.
{
"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 ,还是这些模板只是不能满足这种情况下所需的功能?
Is there a way to selectivly set AppSettings via an ARM Template, or are the templates simply not capale of functioning as desired for such a scenario?
推荐答案
不久前,我也遇到了这个问题,但是在ARM模板中找不到解决方案.
I ran into this problem also a while ago and did not find a solution within an ARM Template.
就我而言,我通过使用PowerShell脚本解决了在ARM模板之后运行的问题.也许您可以使用其中的某些部分:
In my case I solved it by using a PowerShell Script what run after the ARM Template. Maybe you can use some parts of this:
https://gist.github.com/kirkone/2b5996a57a5610a8a41e2bfd1edc37f1
主要部分是获取当前值,添加或覆盖新值并写回完整列表.
该脚本可用于VSTS/TFS,但应为您提供有关如何完成操作的提示.
The main part is getting the current values, add or override with the new values and write back the complete list.
This Script is for use with VSTS / TFS but it should give you a hint about how it can be done.
对不起,没有更好的解决方案,但我希望这对您有所帮助.
Sorry for not having a better solution but I hope this helps also.
CU
柯克
这篇关于不要删除未在模板中声明的AppSettings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!