Skip to content

Files

Latest commit

1c7a994 · Apr 6, 2022

History

History
58 lines (38 loc) · 3.05 KB

container-registry-auth-aci.md

File metadata and controls

58 lines (38 loc) · 3.05 KB
title description ms.topic ms.date
Access from Container Instances
Learn how to provide access to images in your private container registry from Azure Container Instances by using an Azure Active Directory service principal.
article
04/23/2018

Authenticate with Azure Container Registry from Azure Container Instances

You can use an Azure Active Directory (Azure AD) service principal to provide access to your private container registries in Azure Container Registry.

In this article, you learn to create and configure an Azure AD service principal with pull permissions to your registry. Then, you start a container in Azure Container Instances (ACI) that pulls its image from your private registry, using the service principal for authentication.

When to use a service principal

You should use a service principal for authentication from ACI in headless scenarios, such as in applications or services that create container instances in an automated or otherwise unattended manner.

For example, if you have an automated script that runs nightly and creates a task-based container instance to process some data, it can use a service principal with pull-only permissions to authenticate to the registry. You can then rotate the service principal's credentials or revoke its access completely without affecting other services and applications.

Service principals should also be used when the registry admin user is disabled.

[!INCLUDE container-registry-service-principal]

Authenticate using the service principal

To launch a container in Azure Container Instances using a service principal, specify its ID for --registry-username, and its password for --registry-password.

az container create \
    --resource-group myResourceGroup \
    --name mycontainer \
    --image mycontainerregistry.azurecr.io/myimage:v1 \
    --registry-login-server mycontainerregistry.azurecr.io \
    --registry-username <service-principal-ID> \
    --registry-password <service-principal-password>

Sample scripts

You can find the preceding sample scripts for Azure CLI on GitHub, as well versions for Azure PowerShell:

Next steps

The following articles contain additional details on working with service principals and ACR: