在 Azure DevOps 管道中为 WebApp 创建部署槽 [英] Create deployment slot for WebApp in Azure DevOps pipeline

查看:42
本文介绍了在 Azure DevOps 管道中为 WebApp 创建部署槽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 Azure DevOps 管道执行以下操作:

I would like to perform the following operations from an Azure DevOps pipeline:

  • 为现有的 Web 应用程序创建新的部署槽(staging)
  • 将应用程序部署到新槽
  • staging 槽与 production
  • 交换
  • 删除以前的production,现在的staging slot
  • Create new deployment slot for an existing WebApp (staging)
  • Deploy application to new slot
  • Swap staging slot with production
  • Delete former production, now staging slot

到目前为止我所拥有的是:

What I have so far is:

  • 将应用程序部署到新槽
  • staging 槽与生产交换
  • 删除以前的production,现在的staging slot
  • Deploy application to new slot
  • Swap staging slot with production
  • Delete former production, now staging slot

YAML:

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'BizSpark(...)'
    appType: 'webApp'
    WebAppName: 'foo'
    deployToSlotOrASE: true
    ResourceGroupName: 'Default-WestEurope'
    SlotName: 'staging'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

- task: AzureAppServiceManage@0
  inputs:
    azureSubscription: 'BizSpark(..)'
    Action: 'Swap Slots'
    WebAppName: 'foo'
    ResourceGroupName: 'Default-WestEurope'
    SourceSlot: 'staging'

- task: AzureAppServiceManage@0
  inputs:
    azureSubscription: 'BizSpark(..)'
    Action: 'Delete Slot'
    WebAppName: 'foo'
    ResourceGroupName: 'Default-WestEurope'
    Slot: 'staging'

但是,AzureAppServiceManage 任务不提供创建部署槽的方法.

However, AzureAppServiceManage task does not provide a method to create a deployment slot.

如何做到这一点?

推荐答案

我可以使用 powershell 和 Microsft Hosted Agent 在 azure devops 管道中创建一个 WebbApp 插槽,任务如下:

I could create a WebbApp slot in azure devops pipeline by using powershell and Microsft Hosted Agent, here is the task:

根据 文档示例:

- task: AzureCLI@2
    displayName: Azure CLI   
     inputs:
      azureSubscription: <Name of the Azure Resource Manager service connection>
      scriptType: ps
      scriptLocation: inlineScript
      inlineScript: |
          az --version
          az account show

对于内联脚本,我使用了az webapp deployment slot create"Azure CLI 命令:

and for the inline script i used "az webapp deployment slot create" Azure CLI Command:

az webapp deployment slot create --name
                                 --resource-group
                                 --slot
                                 [--configuration-source]
                                 [--subscription]

这有帮助吗?

这篇关于在 Azure DevOps 管道中为 WebApp 创建部署槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆