gpt4 book ai didi

azure - 通过 ARM/msdeploy 部署到 Azure Web App,无需删除现有文件

转载 作者:行者123 更新时间:2023-12-04 11:47:48 24 4
gpt4 key购买 nike

使用常规 msdeploy(又名 WebDeploy,用于 Visual Studio 或 VSTS 发布)部署到 Azure Web App(又名 Azure 应用服务)时,您可以选择删除目标处的现有文件.

但是,当使用 ARM extensions/msdeploy 提供程序(例如通过 ARM 模板)时,默认情况下始终会删除现有文件。有没有办法覆盖它而不破坏现有文件?

最佳答案

Azure Web App 支持 DoNotDeleteRule 的方式是通过 addOnPackages架构元素。

addOnPackages 隐式使用 DoNotDelete 规则。因此,如果您想要应用包而不删除现有站点中的文件,则可以在 addOnPackages 数组中指定它,然后不要在外部 MSDeploy 对象中定义任何内容。例如:

{
"properties": {
"parameters": {
"appName": {
"value": "mysite"
},
"location":{
"value": "USAAnywhere"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0-r188+188.764a8a7798ecc6ebb752343c6f8e6be2903ba711",
"parameters": {
"appName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2016-08-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"type": "Microsoft.Web/sites",
"resources": [
{
"apiVersion": "2016-08-01",
"name": "MSDeploy",
"type": "Extensions",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', parameters('appName'))]"
],
"properties": {
"addOnPackages" : [
{
"packageUri": "https://mystorageblob.blob.core.windows.net/package/my_webdeploy_package.zip",
"AppOffline": true,
"setParameters": {
"IIS Web Application Name": "[parameters('appName')]",
}
}
]
}
}
],
"properties" : {}
}
]
},
"mode": "Incremental"
}
}

addOnPackages 还允许在单个 MSDeploy ARM 模板中包含多个包;外层会删除现有站点的文件,而addOnPackages是附加的,不会删除外层包。例如:

{
"properties": {
"parameters": {
"appName": {
"value": "mysite"
},
"location":{
"value": "USAAnywhere"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0-r188+188.764a8a7798ecc6ebb752343c6f8e6be2903ba711",
"parameters": {
"appName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2016-08-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"type": "Microsoft.Web/sites",
"resources": [
{
"apiVersion": "2016-08-01",
"name": "MSDeploy",
"type": "Extensions",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', parameters('appName'))]"
],
"properties": {
"packageUri": "https://mystorageblob.blob.core.windows.net/package/my_webdeploy_package.zip",
"dbType": "None",
"connectionString": "",
"AppOffline": true,
"SkipAppData": true,
"setParameters": {
"IIS Web Application Name": "[parameters('appName')]"
},
"addOnPackages" : [
{
"packageUri": "https://mystorageblob.blob.core.windows.net/package/my_first_add_on_package.zip",
"AppOffline": true,
"setParameters": {
"IIS Web Application Name": "[parameters('appName')]",
}
},
{
"packageUri": "https://mystorageblob.blob.core.windows.net/package/my_second_add_on_package.zip",
"setParameters": {
"IIS Web Application Name": "[parameters('appName')]",
}
}
]
}
}
],
"properties" : {}
}
]
},
"mode": "Incremental"
}
}

关于azure - 通过 ARM/msdeploy 部署到 Azure Web App,无需删除现有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45868692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com