4
使用常規msdeploy(又名WebDeploy,用於Visual Studio或VSTS發佈)部署到Azure Web App(又名Azure App Service)時,可以選擇不是刪除目標上的現有文件。通過ARM/msdeploy部署到Azure Web App而不刪除現有文件
但是,當使用ARM提供程序(例如,通過ARM模板)時,默認情況下始終刪除現有文件。有沒有辦法來覆蓋這個,而不是吹走現有的文件?
使用常規msdeploy(又名WebDeploy,用於Visual Studio或VSTS發佈)部署到Azure Web App(又名Azure App Service)時,可以選擇不是刪除目標上的現有文件。通過ARM/msdeploy部署到Azure Web App而不刪除現有文件
但是,當使用ARM提供程序(例如,通過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"
}
}
AppOffline和SkipAppData參數是什麼意思? – juvchan
@juvchan:''appOffline「:true'等同於msdeploy -enableRule:AppOffline命令行選項。它默認爲'false'(關閉)。 ''skipAppData「:true'等同於msdeploy -skip:objectname ='dirPath',absolutepath = App_Data'。 – DropPhone