0

I'm in the process of migration my solution from classic pipelines to YAML pipelines in Azure DevOps.

One of the steps in the pipeline is the creation of ACI container from the image I build and push in the previous steps.

When I run this step using YAML pipeline it fails with the message -

"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."

When I run the exact same ACI container creating command from the classic pipeline it works.

I'm using AzureCLI task which looks like this

- 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

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.

kamilwydrzycki
  • 451
  • 2
  • 6
  • 16
  • have you tried AzureCLI@2 ? Just curious. Also from the error message you are getting, it seems you are hitting a an issue with the login to the registy. have a look at this https://stackoverflow.com/questions/49498695/using-azure-container-registry-creating-new-azure-container-instance-from-c-shar – djsly Apr 28 '20 at 02:28
  • One suspicion would be that your local az if configured to access the ACR while the user that azure DevOps' pipeline is using isn't. Also doable check your $PERFORMANCE_TESTING_REGISTRY_NAME and $IMAGE_NAME they should point to the same registry server. – djsly Apr 28 '20 at 02:35
  • Yes, I tried CLI@2 without any luck. – kamilwydrzycki Apr 28 '20 at 07:00
  • Those variables point to the same server. What I did to make sure was to echo that az command with variables substituted with real values. I then copy that command and run it locally with success. – kamilwydrzycki Apr 28 '20 at 07:01
  • As I know the most possible reason is that you set the image with something wrong, wrong name or wrong tag. So are you sure all that right? – Charles Xu Apr 28 '20 at 07:11
  • I've just copy the command and run through classic pipelines and it works. Running the exact same command from YAML pipelines produces the error. – kamilwydrzycki Apr 28 '20 at 07:14
  • Yeah, I also test it with the YAML pipeline and it works fine. So you only get one error you provide in the question? – Charles Xu Apr 28 '20 at 07:20
  • Yes, this is the only error. – kamilwydrzycki Apr 28 '20 at 07:23
  • I still insist on what I said. That's the possible reason for the error. What is the image name you set? – Charles Xu Apr 28 '20 at 07:27
  • This is image name I use - performanceregistry.azurecr.io/performancerunner:1.0 – kamilwydrzycki Apr 28 '20 at 07:29
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/212672/discussion-between-charles-xu-and-kamilwydrzycki). – Charles Xu Apr 28 '20 at 07:35

1 Answers1

0

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.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39