Methods to Login Azure Container Registry

Yst@IT
3 min readDec 31, 2020

--

There are several ways to authenticate with an Azure container registry, each of which is applicable to one or more registry usage scenarios.

Recommended ways include authenticating to a registry directly via individual login, or your applications and container orchestrators can perform unattended, or “headless,” authentication by using an Azure Active Directory (Azure AD) service principal.

I will show the steps using service principal and admin user method to login in ACR.

Using admin user is relatively easy, just enable it and you are good to go.

Azure ACR and Service Principal

Let verify it using docker command.

Azure ACR and Service Principal

OK, I am login to ACR, let’s upload a image to it.

Azure ACR and Service Principal

OK, done uploading to ACR, let’s check it from console.

Azure ACR and Service Principal

Next, let’s use service principal as authentication method and push image to ACR. Using S.P is a little bit complicated, the steps are:

  1. Register application with AAD and create a S.P
  2. Assign a role to the application
  3. Get client ID and application secret
  4. Verity if login is successful
Azure ACR and Service Principal

Name the application, leave the rest as default and click Register at the bottom.

Azure ACR and Service Principal

Once done, the overview information is as below. Drop down the Application ID as we will need it to login.

Azure ACR and Service Principal

There are two authentication options available for service principals. I will use password-based authentication for convenience.

Azure ACR and Service Principal

Copy the value as it is your login password.

Azure ACR and Service Principal

Now we have the service principal ready, we need to assign permission to it by assigning role. We can assign permission on subscription, resource group or resource level. Let’s assign permission on resource level, which is ACR itself.

Azure ACR and Service Principal

Once done, let’s login ACR from command line.

Azure ACR and Service Principal

Now let’s verify if we can upload image to ACR.

Azure ACR and Service Principal
Azure ACR and Service Principal

And it is a success!

In next post, I will attach this ACR with Azure AKS so that AKS can build containers from this ACR. Stay tune!

Reference:

How to: Use the portal to create an Azure AD application and service principal that can access resources

--

--

Yst@IT

Cloud Solution Architect, focusing on Oracle Cloud Infrastructure currently.