azure - Azure Function ARM 模板删除不属于模板文件的现有应用程序设置
问题描述
我使用 ARM 模板创建了具有默认应用程序设置的函数应用程序。不幸的是,在部署 ARM 模板时,它删除了所有未在 ARM 模板中定义的应用程序设置。
这是用于函数应用的 ARM 模板:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"functionAppName": {
"type": "string",
"defaultValue": "[concat('fnapp', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
"newOrExisting": {
"type": "string",
"allowedValues": [
"new",
"existing"
],
"metadata": {
"description": "Choose the app service plan based on these values"
}
},
"existingHostingPlanName": {
"type": "string",
"metadata": {
"description": "The name of the existing hosting plan"
}
},
"existingResourceGroupName": {
"type": "string",
"metadata": {
"description": "The name of the existing resource group"
}
},
"newHostingPlanName": {
"type": "string",
"metadata": {
"description": "The name of the new hosting plan"
}
},
"sku": {
"type": "string",
"allowedValues": [
"D1",
"F1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P1V2",
"P2V2",
"P3V2",
"I1",
"I2",
"I3",
"Y1"
],
"defaultValue": "S1",
"metadata": {
"description": "The pricing tier for the hosting plan."
}
},
"workerSize": {
"type": "string",
"allowedValues": [
"0",
"1",
"2"
],
"defaultValue": "0",
"metadata": {
"description": "The instance size of the hosting plan (small, medium, or large)."
}
},
"applicationInsightsName": {
"type": "string",
"metadata": {
"description": "The Application Insights Name."
}
},
"storageAccountName": {
"type": "string",
"metadata": {
"description": "Name of the Storage Account."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"runtime": {
"type": "string",
"defaultValue": "dotnet",
"allowedValues": [
"node",
"dotnet",
"java"
],
"metadata": {
"description": "The language worker runtime to load in the function app."
}
},
"identityType": {
"type": "string",
"metadata": {
"description": "The Identity type"
}
},
"functionRuntimeVersion": {
"type": "string",
"defaultValue": "~3",
"metadata": {
"description": "The runtime version for the function app"
}
}
},
"variables": {
"serverFarmId": "[ if(equals(parameters('newOrExisting'),'new'),resourceId('Microsoft.Web/serverfarms',parameters('newHostingPlanName')), concat(subscription().id,'/resourceGroups/',parameters('existingResourceGroupName'),'/providers/Microsoft.Web/serverfarms/',parameters('existingHostingPlanName')))]",
"functionWorkerRuntime": "[parameters('runtime')]"
},
"resources": [
{
"condition": "[equals(parameters('newOrExisting'),'new')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-06-01",
"name": "[parameters('newHostingPlanName')]",
"location": "[parameters('location')]",
"sku": {
"Name": "[parameters('sku')]"
},
"properties": {
"name": "[parameters('newHostingPlanName')]",
"workerSize": "[parameters('workerSize')]",
"numberOfWorkers": 1
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-06-01",
"name": "[parameters('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('applicationInsightsName'))]"
],
"identity": {
"type": "[parameters('identityType')]"
},
"properties": {
"serverFarmId": "[variables('serverFarmId')]",
"httpsOnly": true,
"siteConfig": {
"alwaysOn": true,
"ftpsState": "FtpsOnly",
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('functionAppName'))]"
},
{
"name": "WEBSITE_RUN_FROM_PACKAGE",
"value": "1"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "[parameters('functionRuntimeVersion')]"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components', parameters('applicationInsightsName')), '2020-02-02-preview').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[variables('functionWorkerRuntime')]"
}
]
}
}
},
{
"type": "microsoft.insights/components",
"apiVersion": "2020-02-02-preview",
"name": "[parameters('applicationInsightsName')]",
"location": "[parameters('location')]",
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites', parameters('applicationInsightsName')))]": "Resource"
},
"properties": {
"ApplicationId": "[parameters('applicationInsightsName')]",
"Request_Source": "IbizaWebAppExtensionCreate"
}
}
],
"outputs": {}
}
我已经提到了这个git hub 问题,但它仍然是开放的。
那么,谁能建议我如何解决这个问题?
解决方案
这是正常现象,当你部署模板时,有两种模式,Complete
和Incremental
,但即使有Incremental
模式,如果你提供新的值appsettings
,作为子资源的那个Microsoft.Web/sites/config
会被覆盖(web app和function app是一样的) .
因此,在您的情况下,如果您想保留默认设置,您还需要将它们添加到您的模板中。
推荐阅读
- scala - scalaz中的存储是什么
- logstash - 无法读取 logstash 中的 .gz 文件
- amazon-web-services - Amazon kinesis 多个出版商
- django - 如何在 Django 中跟踪表单错误?
- python - 无法使用 Rectbivariatespline 对网格网格上的二维数组进行插值
- python - 值和身份的元组相同,但身份测试(是)在 python 中为假
- c# - 如何在字典列表中使用 .Distinct()?C#
- javascript - 使用 getJSON 中的 JSON/AJAX 信息更改多个 iframe 的 src 以包含取自 YouTube API 的 videoId
- node.js - 重命名上传的文件时出现 ENOENT 错误
- machine-learning - 使用 Keras 进行特征提取不包括类标签