我们正在将Azure devop用于我们的CI / CD。通常,所有配置项都被编写为azure yaml文件,并且必须在devops门户(使用GUI)上创建发布作业。我们要遵循的一般原则之一是将所有内容都作为代码。
问题:
答案 0 :(得分:0)
Azure 部署可以使用代码进行配置。您可以添加多个发布触发器(管道、拉取请求等)。可以为每个环境 (https://www.programmingwithwolfgang.com/deployment-approvals-yaml-pipeline/) 配置批准,然后在您的管道中引用环境。
以下示例在其自身的 yaml 代码更改以及 Build 管道完成时触发。
trigger:
branches:
include:
- myBranch
paths:
include:
- '/Deployment/azure-deploy.yml'
resources:
pipelines:
- pipeline: BuildPipeline
project: myProjectName
source: 'myBuildPipeline'
trigger:
enabled: true
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(environment)
pool:
vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: Deploy Web App
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(azureSubscription)
appType: 'webApp'
appSettings:
-SETTING-1 "$(mySetting1)"
WebAppName: '$(myAppName)'
package: '$(Pipeline.Workspace)/**/*.zip'
[1]: https://www.programmingwithwolfgang.com/deployment-approvals-yaml-pipeline/