azure - Azure DevOps Release Pipeline 淘汰了应用服务部署槽
问题描述
我正在构建一个基本上有 2 个部分的 Azure DevOps 发布管道:
部署构建应用计划、应用服务、部署槽、配置设置的 Arm 模板。注意:我正在以“增量模式”部署 ARM 模板,因此如果模板没有更改,则此任务不应对环境进行任何更改。
将 Web 应用的代码部署到暂存槽。
目标显然是在没有 ARM 模板的情况下创建环境,或者在第一次“正确设置”环境后部署的情况下,如果基础设施存在偏差。您希望基础设施即代码完成的所有事情。
然后第二部分将应用程序的最新版本部署到暂存槽,以便在将其交换到生产环境之前对其进行冒烟测试。
最初的第一个部署按预期工作,但第二个部署没有对 ARM 模板进行任何更改,并且部署了新版本的应用程序没有按预期工作。运行 Release Pipeline 后,我希望在生产槽中找到应用程序的版本 1,在暂存槽中找到版本 2。相反,我发现的是暂存槽和一个空的生产槽中的应用程序版本 2。这显然会导致生产中断,所以我知道我必须做错事。
如果我运行管道的 ARM 模板部署步骤,它要么清除生产槽中的应用程序版本 1,要么交换槽并在版本 1 上部署应用程序的版本 2。
我是不是做错了,ARM 模板需要在它自己的管道中,因为它的预期行为会消灭生产槽?同样,我正在以“增量模式”部署 ARM 模板。
期望的行为:我希望当管道再次运行时,ARM 模板将使之前部署在生产槽中的代码保持原样。相反,在代码部署任务运行后,新代码将部署到 vNext(暂存)槽,生产槽为空,库存“您的应用服务已启动并正在运行。是时候采取下一步并部署您的代码了。” 信息。
发布管道有 2 个任务:
ARM Template Deployment V3 (Microsoft)
部署模式:增量Azure App Service Deploy V4 (Microsoft)
Deploy to Slot or App Service Environment:选中
提供的资源组和插槽名称
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"
推荐阅读
- asp.net - 是否可以使用接口扩展现有对象?
- leaflet - Nuxt Leaflet,更改瓷砖层请求不正确的瓷砖
- postgresql - RDS cloudwatch 指标“可用存储空间”不会通过 drop table 释放
- database - 在 DynamoDB 中预加入学生、班级和成绩
- python-3.x - 需要帮助理解带有递归的链表(Python)
- python - Python 在格式化字符串中使用 kwargs:期望字符串,获取字典?
- python - Pygame - 图像弄脏/在屏幕上留下痕迹
- php - 在 wordpress 中一次获取多个导航菜单
- laravel - 如何在 Laravel 中检索以子属性为条件的父记录集合
- vb.net - ComboBox SelectedIndexChanged 不返回所选值