我正在做一个发布管道,在我的代理任务期间,我找不到一种使用yaml文件的方法。
在发布管道中创建Azure容器组的最佳实践是什么?我一直在寻找Microsoft的文档,找不到合适的示例。
我正在考虑使用Azure CLI作业并通过deploy.yaml文件在本地进行操作来创建ACR。
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'
希望它对您有帮助,如果您还有其他问题,请告诉我。