![](/img/trans.png)
[英]App Service does not load web-app after successful deployment from Azure DevOps release pipeline
[英]Azure DevOps Release Pipeline wipes out App Service Deployment Slot
我正在構建一個 Azure DevOps 發布管道,它基本上有兩個部分:
部署 Arm 模板,用於構建應用計划、應用服務、部署槽、配置設置。 注意:我正在以“增量模式”部署 ARM 模板,因此如果模板未更改,則此任務不應對環境進行任何更改。
將 Web 應用程序的代碼部署到暫存槽。
目標顯然是在 ARM 模板不存在的情況下創建環境,或者如果在基礎架構中存在漂移,則在第一次“設置正確”環境之后進行部署的情況下。 您希望基礎設施即代碼做的所有事情。
然后第二部分將應用程序的最新版本部署到暫存槽,以便在將其交換到生產環境之前對其進行冒煙測試。
最初的第一次部署按預期工作,但第二次部署沒有對 ARM 模板進行更改,並且部署了新版本的應用程序,但沒有按預期工作。 運行發布管道后,我希望在生產槽中找到應用程序的版本 1,在暫存槽中找到版本 2。 相反,我在暫存槽和一個空的生產槽中找到了應用程序的第 2 版。 這顯然會導致生產中斷,所以我知道我一定做錯了什么。
如果我運行流水線的 ARM 模板部署步驟,它要么清除生產槽中的應用程序版本 1,要么交換槽並在版本 1 上部署應用程序的版本 2。
我做錯了嗎,ARM 模板需要在它自己的管道中,因為它的預期行為會消除生產槽? 同樣,我正在以“增量模式”部署 ARM 模板。
期望的行為:我希望當流水線再次運行時,ARM 模板將使之前部署在生產槽中的代碼保持完整。 相反,在代碼部署任務運行后,新代碼將部署到 vNext(暫存)槽,生產槽為空,並顯示“您的應用服務已啟動並正在運行。是時候進行下一步並部署您的代碼了。” 信息。
發布管道有 2 個任務:
ARM 模板部署 V3 (Microsoft)
部署方式:增量
Azure 應用服務部署 V4 (Microsoft)
部署到插槽或應用服務環境:選中
提供了資源組和插槽名稱
ARM模板:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"hostingPlanName": {
"type": "string"
},
"webAppName": {
"type": "string"
},
"skuTier": {
"type": "string"
},
"skuName": {
"type": "string"
},
"appInsightsName": {
"type": "string"
},
"ceEndPoint": {
"type": "string"
},
"ceStoreRoute": {
"type": "string"
},
"ceMask1": {
"type": "string"
},
"ceMask2": {
"type": "string"
},
"ceClientValidateURL": {
"type": "string"
},
"ceClientId": {
"type": "string"
},
"ceClientNo": {
"type": "string"
},
"stagingSlotName": {
"type": "string",
"minLength": 1
}
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "[parameters('webAppName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('location')]",
"tags": {
"SCSU Department": "ITS",
"SCSU SME": "MAA"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
],
"properties": {
"name": "[parameters('webAppName')]",
"serverFarmId": "[concat('/subscriptions/', subscription().subscriptionId,'/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"httpsOnly": true
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName'))).InstrumentationKey]",
"ApplicationInsightsAgent_EXTENSION_VERSION": "~2",
"XDT_MicrosoftApplicationInsights_Mode": "recommended",
"DiagnosticServices_EXTENSION_VERSION": "disabled",
"APPINSIGHTS_PROFILERFEATURE_VERSION": "disabled",
"APPINSIGHTS_SNAPSHOTFEATURE_VERSION": "disabled",
"InstrumentationEngine_EXTENSION_VERSION": "disabled",
"SnapshotDebugger_EXTENSION_VERSION": "disabled",
"XDT_MicrosoftApplicationInsights_BaseExtensions": "disabled",
"ceEndPoint": "[parameters('ceEndPoint')]",
"ceStoreRoute": "[parameters('ceStoreRoute')]",
"ceMask1": "[parameters('ceMask1')]",
"ceMask2": "[parameters('ceMask2')]",
"ceClientValidateURL": "[parameters('ceClientValidateURL')]",
"ceClientId": "[parameters('ceClientId')]",
"ceClientNo": "[parameters('ceClientNo')]"
}
}
]
},
{
"apiVersion": "2018-02-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('location')]",
"kind": "web",
"tags": {
"SCSU Department": "ITS",
"SCSU SME": "MAA"
},
"dependsOn": [],
"properties": {
"name": "[parameters('hostingPlanName')]",
"reserved": false
},
"sku": {
"tier": "[parameters('skuTier')]",
"name": "[parameters('skuName')]"
}
},
{
"apiVersion": "2018-11-01",
"name": "[concat(parameters('webAppName'), '/', parameters('stagingSlotName'))]",
"type": "Microsoft.Web/sites/slots",
"location": "[parameters('location')]",
"tags": {
"SCSU Department": "ITS",
"SCSU SME": "MAA"
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"properties": {
},
"resources": []
},
{
"apiVersion": "2015-05-01",
"name": "[parameters('appInsightsName')]",
"type": "microsoft.insights/components",
"location": "[parameters('location')]",
"kind": "string",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"tags": {
"SCSU Department": "ITS",
"SCSU SME": "MAA"
},
"properties": {
"Application_Type": "web",
"ApplicationId": "[parameters('webAppName')]"
}
}
]
}
如果您的 Web 應用程序從包運行,我認為這是 Azure DevOps 應用服務部署任務中的默認設置,您需要在 ARM 模板中添加以下應用設置:
"WEBSITE_RUN_FROM_PACKAGE": "1"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.