如何配置Azure管道审批检查以部署到azure函数应用程序?

问题描述 投票:0回答:1

我们有 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'
azure-devops azure-functions azure-pipelines
1个回答
0
投票

环境我用作

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
作业。


© www.soinside.com 2019 - 2024. All rights reserved.