从发布管道创建 Azure 实例组

Create a Azure Instance group from Release pipelines

我正在做一个发布管道,但我找不到在我的代理任务期间使用 yaml 文件的方法。

在发布管道期间创建 Azure 容器组的最佳做法是什么?我一直在 Microsoft 寻找文档,但找不到合适的示例。

我正在考虑使用 Azure CLI 作业并创建 ACR,就像我在本地使用 deploy.yaml 文件一样。

az container create --resource-group myResourceGroup --file deploy-aci.yaml

deploy.yaml 文件示例

apiVersion: 2018-10-01
location: northeurope
name: e2e
properties:
  containers:
  - name: e2etestcafe
    properties:
      image: n1containers.azurecr.io/e2e/e2etestcafe:latest
      resources:
        requests:
          cpu: 2
          memoryInGb: 8
  - name: customerportal
    properties:
      image: n1containers.azurecr.io/e2e/customerportal:latest
      resources:
        requests:
          cpu: 1
          memoryInGb: 1
      ports:
      - port: 80
  osType: Linux
tags: null
type: Microsoft.ContainerInstance/containerGroups

无论如何我都找不到向该作业添加文件。我使用了错误的工具来执行此操作,有没有一种方法可以使用我用来创建容器组的现有 yaml 文件创建发布管道?

根据您的要求,也许您是对的,Azure DevOps 不支持直接创建容器实例。所以你通过CLI命令创建容器实例的决定是正确的。

按照您展示的方式使用 CLI,我不知道您选择哪个存储库,我假设您使用的是 Azure Repos,因此您需要先创建用于创建容器实例的 YAML 文件。然后你可以像这样设置内联脚本:

内联脚本是您唯一需要设置的脚本,然后只需保存并运行即可。

或者您可以使用 pipeline.yaml 像这样设置 DevOps 作业:

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: AzureCLI@2
  inputs:
    azureSubscription: 'Azure CXP Community Internal Consumption(b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f)'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: 'az container create --resource-group charles --file $(System.DefaultWorkingDirectory)/aci.yaml'

希望对您有所帮助,如果您还有其他问题,请告诉我。