简体   繁体   English

Azure 来自 Azure DevOps YAML 管道的容器实例创建问题

[英]Azure Container Instance creation issue from Azure DevOps YAML pipeline

I'm in the process of migration my solution from classic pipelines to YAML pipelines in Azure DevOps.我正在将我的解决方案从经典管道迁移到 Azure DevOps 中的 YAML 管道。

One of the steps in the pipeline is the creation of ACI container from the image I build and push in the previous steps.管道中的步骤之一是从我在前面的步骤中构建和推送的映像创建 ACI 容器。

When I run this step using YAML pipeline it fails with the message -当我使用 YAML 管道运行此步骤时,它失败并显示消息 -

"The image 'registry.azurecr.io/performancerunner:1.0' in container group 'performance-testing-container-group' is not accessible. Please check the image and registry credential." “容器组 'performance-testing-container-group' 中的映像 'registry.azurecr.io/performancerunner:1.0' 不可访问。请检查映像和注册表凭据。”

When I run the exact same ACI container creating command from the classic pipeline it works.当我从经典管道运行完全相同的 ACI 容器创建命令时,它可以工作。

I'm using AzureCLI task which looks like this我正在使用看起来像这样的 AzureCLI 任务

- task: AzureCLI@1
  displayName: 'Run performance tests'
  inputs:
    azureSubscription: $(AZURE_SUBSCRIPTION)
    scriptType: 'bash'
    scriptLocation: 'scriptPath'
    scriptPath: 'LoadTesting/deployment/scripts/run_tests.sh' 

The content of the run_tests.sh looks like this run_tests.sh 的内容如下所示

az container create -g $PERFORMANCE_TESTING_RG_NAME --registry-login-server "$PERFORMANCE_TESTING_REGISTRY_NAME.azurecr.io" --registry-username $PERFORMANCE_TESTING_REGISTRY_NAME \
--registry-password $REGISTRY_PASSWORD --image $IMAGE_NAME \
-n $PERFORMANCE_TESTING_CONTAINER_NAME --cpu 1 --memory 8 --restart-policy Never \
--command-line "dotnet LoadTests.dll -n testApp -c 1000"

When I echo this command, copy it with variables substituted from the logs and run it locally it works fine.当我回显这个命令时,用从日志中替换的变量复制它并在本地运行它工作正常。

For your issue, the problem is that the error you got shows.对于您的问题,问题在于您得到的错误显示。 You will get the error in two situations.你会在两种情况下得到错误。 One is that your image with the tag is not right in the registry that you used.一是带有标签的图像在您使用的注册表中不正确。 And another is that the credential of the registry is not right.另一个是注册表的凭据不正确。

With the messages, it seems it's all right for your image.有了这些消息,您的形象似乎没问题。 Then you need to focus on another reason of the two.然后你需要关注两者的另一个原因。 You set the credential through the variables, so I think a good way is to output the variables to check if it's right.您通过变量设置凭证,所以我认为一个好方法是 output 变量检查它是否正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM