ARM模板中特定于部署插槽的appsettin? [英] Deployment slot specific appsettin in ARM template?
问题描述
我正在尝试进入该Visual Studio资源组模板. 到目前为止,它看起来不错,并且我为Web应用程序添加了一些应用程序设置,但是我的问题是,如何使它们特定于部署插槽?模板或参数文件的json中有东西吗?
I'm trying to get into that Visual Studio Resource Group template. So far it's looking good, and I have added some appsettings for a web app, but my question is, how can I make them deployment slot specific? Is there something in the json for the template or the parameter file?
推荐答案
请尝试添加添加到ARM模板中的json代码.我已经测试过了它可以成功工作.
Please have a try to add the json code snipped in the ARM template. I have tested it. It works successfully.
"resources": [
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'), 'Staging')]"
],
"properties": {
"AppSettingKey1": "Some staging value",
"AppSettingKey2": "My second staging setting",
"AppSettingKey3": "My third staging setting"
}
}
]
以下是我的详细步骤:
1. Create a new Azure Resource group project (More detail please refer to document)
2.该演示仅用于Azure网站插槽应用程序设置配置,因此请从项目中删除其他资源.
3.将插槽配置添加到部署文件中
4.发布部署
完整的json代码:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"hostingPlanName": {
"type": "string",
"minLength": 1
},
"skuName": {
"type": "string",
"defaultValue": "S1",
"allowedValues": [
"F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P4"
],
"metadata": {
"description": "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"skuCapacity": {
"type": "int",
"defaultValue": 1,
"minValue": 1,
"metadata": {
"description": "Describes plan's instance count"
}
}
},
"variables": {
"webSiteName": "[concat('webSite', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "HostingPlan"
},
"sku": {
"name": "[parameters('skuName')]",
"capacity": "[parameters('skuCapacity')]"
},
"properties": {
"name": "[parameters('hostingPlanName')]"
}
},
{
"apiVersion": "2015-08-01",
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
],
"location": "[resourceGroup().location]",
"name": "[variables('webSiteName')]",
"properties": {
"name": "[variables('webSiteName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "Staging",
"type": "slots",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
],
"properties": {
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'), 'Staging')]"
],
"properties": {
"AppSettingKey1": "Some staging value",
"AppSettingKey2": "My second staging setting",
"AppSettingKey3": "My third staging setting"
}
}
]
}
],
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
"displayName": "Website"
},
"type": "Microsoft.Web/sites"
}
]
}
如果您在Azure门户上有任何插槽,我们还可以从 azure资源中获取插槽类型. . 我还在SO中找到了类似的线程.
We also can get the slot type from the azure resource ,if you have any slots on the Azure portal. I also find a similar thread in the SO.
这篇关于ARM模板中特定于部署插槽的appsettin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!