Azure 终止其中一个容器时停止容器实例组

Azure 终止其中一个容器时停止容器实例组,azure,containers,azure-container-instances,Azure,Containers,Azure Container Instances,我正在创建一个容器组,其中包含一个在网站上运行E2E的容器。当其中一个容器停止运行时,如何停止整个组?(在这种情况下,E2E测试) 我通过一个管道创建这个,我需要在测试完成后停止前端容器 apiVersion: 2018-10-01 location: northeurope name: e2e-uat properties: containers: # name of the instance in Azure. - name: e2etestcafe prop

我正在创建一个容器组,其中包含一个在网站上运行E2E的容器。当其中一个容器停止运行时,如何停止整个组?(在这种情况下,E2E测试)

我通过一个管道创建这个,我需要在测试完成后停止前端容器

apiVersion: 2018-10-01
location: northeurope
name: e2e-uat
properties:
  containers:
    # name of the instance in Azure.
    - name: e2etestcafe
      properties:
        image: registry.azurecr.io/e2e/e2etestcafe:latest
        resources:
          requests:
            cpu: 1
            memoryInGb: 3
    - name: customerportal
      properties:
        image: registry.azurecr.io/e2e/customerportal:latest
        resources:
          requests:
            cpu: 1
            memoryInGb: 1
        ports:
          - port: 80
  osType: Linux
  restartPolicy: never
tags: null
type: Microsoft.ContainerInstance/containerGroups

对于这个需求,ACI没有我所知道的您所期望的特性。所以你需要自己检查容器的状态

我建议您创建一个带有循环的脚本来检查容器的状态,直到它满足您期望的情况,然后停止整个容器组。在Azure DevOps中,您可以使用包含三个阶段的发布管道,一个用于创建,第二个用于通过运行脚本检查状态,第三个用于停止容器组

要检查容器的状态,我认为下面的CLI命令很有用:

az container show -g myResourceGroup -n myContainerGroup --query containers[*].instanceView.currentState.state
它将输出数组中所有容器的状态