使用 ACR 作为容器资源

Use ACR as a Container Resource

在 Azure Devops 中,您可以使用 "container resources" 在容器中 运行 管道,我正在尝试使用推送到私有 acr 存储库的容器,但我终生不能我发现任何可以让你连接它的东西。我设置了 "service connection" 并允许管道使用它。这是资源部分:

resources:
  containers:
  - container: infrastructure
    image: <acr-registry>.azurecr.io/<private-image>
    env:
      ARM_ACCESS_KEY: "$(arm_access_key)"
      ARM_CLIENT_ID: "$(arm_client_id)"
      ARM_CLIENT_SECRET: "$(arm_client_secret)"
      ARM_SUBSCRIPTION_ID: "$(arm_subscription_id)"

现在根据这个你必须指定你想要使用 "service connection" https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml but in the yaml documentation (https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#resources) 我没有看到任何地方可以在资源部分指定要使用的服务连接

如果想在构建过程中使用容器,可以参考官方文档:

resources:
  containers:
  - container: string  # identifier (A-Z, a-z, 0-9, and underscore)
    image: string  # container image name
    options: string  # arguments to pass to container at startup
    endpoint: string  # endpoint for a private container registry
    env: { string: string }  # list of environment variables to add
    ports: [ string ] # ports to expose on the container
    volumes: [ string ] # volumes to mount on the container

您需要使用端点来指定 docker 您要使用的注册表连接

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#resources