不要删除未在模板中声明的 AppSettings [英] Don't delete AppSettings not declared in a template

查看:15
本文介绍了不要删除未在模板中声明的 AppSettings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过ARM模板部署Azure Function AppAppSettings时,是否可以告诉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 配置,并假设我正在更新现有的功能应用.在这种情况下,名为 storageaccountname_STORAGEAppSetting 将被删除,这是不可取的,因为(例如)创建它是为了促进绑定.

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.

就我而言,我通过使用在 ARM 模板之后运行的 PowerShell 脚本解决了这个问题.也许您可以使用其中的某些部分:

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/2b5996a57a5610a8a41e237fd>

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屋!

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