首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从发布管道创建Azure实例组

从发布管道创建Azure实例组
EN

Stack Overflow用户
提问于 2020-04-15 00:39:02
回答 1查看 72关注 0票数 0

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

在发布管道期间创建Azure容器组的最佳实践是什么?我一直在找微软的文档,但找不到合适的例子。

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

代码语言:javascript
运行
复制
az container create --resource-group myResourceGroup --file deploy-aci.yaml

deploy.yaml文件示例

代码语言:javascript
运行
复制
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

我找不到任何方式来添加文件到此作业。我使用了错误的工具来做这件事,有没有一种方法可以用我用来创建Container Group的现有yaml文件创建一个发布管道?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-15 14:26:55

对于您的需求,也许您是对的,Azure DevOps不支持直接创建容器实例。因此,您通过CLI命令创建容器实例的决定是正确的。

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

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

或者,您可以使用pipeline.yaml设置DevOps作业,如下所示:

代码语言:javascript
运行
复制
# 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'

希望它能帮助你,如果你还有任何问题,请让我知道。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61212750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档