azure-devopsazure-pipelinesaws-ecr

Azure pipeline service container - image from AWS ECR


I've been trying to pull a service container from AWS ECR in azure pipeline but I'm not sure how to perform the "aws ecr get-login" from the pipeline.yml. Here is what I have in my azure pipeline.yml but of course I'm getting "no basic auth credentials" error. Can anyone shed some lights on how to pull image from AWS ECR in azure pipeline service container ?

resources:
  containers:
  - container: sqlDB
    image: 1511260612345.dkr.ecr.ap-southeast-2.amazonaws.com/sqlDB:latest
    options: --name myDB
    env:
      ACCEPT_EULA: Y
      SA_PASSWORD: myPass123!

services:
  sql_db: sqlDB

I have also tried to connect to the AWS endpoint but stupidly azure pipeline only allows docker registry and its own azure container registry.

"The pipeline is not valid. Expected 'dockerregistry' service connection type for image registry referenced by sqlDB, but got AWS for service connection aws_test."


Solution

  • Your pipeline is correct and what mentioned by @4c74356b41 by adding "endpoint" is also correct.

    Following is the Step by step instructions:

    1. Assuming you have AWS access and secret key, you need to create profile credential or you can do "aws configure". After that execute the following command:

    aws ecr get-login --no-include-email --region [enter you region here]

    or if you have aws profile

    aws ecr get-login --no-include-email --profile [enter your aws profile] --region [enter you region here]

    The copy the password section (after "-p") from the above output (you will need to paste it in the docker registry below).

    1. Go to project settings -> Service Connections -> select "Docker Registry" from the new service connection dropdown

    enter image description here

    1. Enter the detail as follow:

    enter image description here

    1. set your endpoint in the pipeline.yml to "aws_test"