title | description | services | author | ms.service | ms.topic | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|
include file |
include file |
container-registry |
dlepow |
container-registry |
include |
12/14/2018 |
danlep |
include file |
To create a service principal with access to your container registry, run the following script in the Azure Cloud Shell or a local installation of the Azure CLI. The script is formatted for the Bash shell.
Before running the script, update the ACR_NAME
variable with the name of your container registry. The SERVICE_PRINCIPAL_NAME
value must be unique within your Azure Active Directory tenant. If you receive an "'http://acr-service-principal' already exists.
" error, specify a different name for the service principal.
You can optionally modify the --role
value in the az ad sp create-for-rbac command if you want to grant different permissions. For a complete list of roles, see ACR roles and permissions.
After you run the script, take note of the service principal's ID and password. Once you have its credentials, you can configure your applications and services to authenticate to your container registry as the service principal.
[!code-azurecli-interactiveacr-sp-create]
To grant registry access to an existing service principal, you must assign a new role to the service principal. As with creating a new service principal, you can grant pull, push and pull, and owner access, among others.
The following script uses the az role assignment create command to grant pull permissions to a service principal you specify in the SERVICE_PRINCIPAL_ID
variable. Adjust the --role
value if you'd like to grant a different level of access.
[!code-azurecli-interactiveacr-sp-role-assign]