我们有 2 个管道可以部署到我们的 Azure 函数应用程序。一份用于开发,一份用于生产。开发者会自动触发,不需要任何批准。但 Prod 需要手动触发并需要批准检查。两个管道都使用相同的服务连接。不确定如何配置批准检查,因为当我进入环境时,我只能添加“Kuberneties”和“虚拟机”作为资源。
trigger:
branches:
include:
- master
paths:
include:
- function-app/**
resources:
repositories:
- repository: aomdevops
type: git
name: AOM-Core/AOM-Devops
variables:
- name: postmanEnv
value: "postman/telco_local.postman_environment.json"
pool:
vmImage: ubuntu-latest
stages:
- stage: Deploy
jobs:
- job: DeployExtractInfo
displayName: "Deploy Extract Info"
steps:
- template: templates/funcapp-deployment.yaml
parameters:
faName: 'funcapp-xxxxxxxxx'
resourceGroup: 'xxxxxxxxxxxxxxxx'
azureSvcConn: 'aom-azure'
funcAppFolder: 'function-app/xxxxxxxxxxx/'
funcAppName: 'exInfo'
- job: DeployErrorHandling
displayName: "Deploy Error Handling"
steps:
- template: templates/funcapp-deployment.yaml
parameters:
faName: 'xxxxxxxxxxxxxxxxxxxxxx'
resourceGroup: 'xxxxxxxxxxxxxxxxx'
azureSvcConn: 'aom-azure'
funcAppFolder: 'function-app/xxxxxxxxxx/'
funcAppName: 'errHandling'
环境我用作
deployment
类型作业的部署目标。请参阅“jobs.deployment 定义”和“jobs.deployment.environment 定义”。
jobs:
- deployment: deploy
environment: environmentName.resourceName
. . .
目前,Environments
中支持的资源类型(
resourceType
)只有virtualMachine
和Kubernetes
。不支持 Azure Function App。
ManualValidation@0
任务在 YAML 管道中设置手动批准,如下所示。
# azure-pipelines.yml
stages:
- stage: Deploy
jobs:
- job: approval
displayName: 'Wait for Approval'
pool: server
timeoutInMinutes: 4320
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440
inputs:
notifyUsers: |
[email protected]
[email protected]
instructions: 'Please validate and approve this deployment.'
- job: DeployExtractInfo
displayName: 'Deploy Extract Info'
dependsOn: approval
. . .
- job: DeployErrorHandling
displayName: 'Deploy Error Handling'
dependsOn: approval
. . .
使用此方法,当运行
Deploy
阶段时,会先运行approval
作业等待指定用户批准。一旦获得批准,它将开始运行后续的 DeployExtractInfo
和 DeployErrorHandling
作业。