Edit

Share via


Microsoft Entra attribute-based access control (ABAC) for repository permissions (Preview)

Azure Container Registry (ACR) supports Microsoft Entra attribute-based access control (ABAC) for managing repository permissions. This feature enhances security by enabling more granular permissions management to container registry repositories. ABAC builds upon Microsoft Entra role-based access control (RBAC) by introducing repository-specific conditions in role assignments.

ABAC is designed for managing repository permissions with Microsoft Entra role-based access control (RBAC), Microsoft Entra role assignments, and Microsoft Entra identities. For managing repository permissions without Microsoft Entra, use non-Microsoft Entra token-based repository permissions instead.

Configure registry role assignment permissions mode

To use Microsoft Entra ABAC to manage repository permissions, ensure the registry role assignment permissions mode is set to "RBAC Registry + ABAC Repository Permissions." This mode allows you to use RBAC role assignments (using ACR built-in roles) with optional ABAC conditions to scope role assignments to specific repositories.

You can configure a registry's role assignment permissions mode either during registry creation or by updating an existing registry. This role assignment can be done either through the Azure portal or Azure CLI. You can enable ABAC for any registry, regardless of its SKU.

Note

Ensure that you have the latest version of the Azure CLI installed by running the Azure CLI command az upgrade. Additionally, if you have previously participated in the private preview of this feature, you may have installed a custom private preview extension to manage ACR ABAC. This custom extension is no longer needed and should be uninstalled (to avoid conflicts) by running the Azure CLI command az extension remove --name acrabac.

Effect on existing role assignments

Important

If you configure a registry to use "RBAC Registry + ABAC Repository Permissions," some existing role assignments aren't honored, because a different set of ACR built-in roles apply to ABAC-enabled registries.

For example, the AcrPull, AcrPush, and AcrDelete roles aren't honored in an ABAC-enabled registry. Instead, in ABAC-enabled registries, use the Container Registry Repository Reader, Container Registry Repository Writer, and Container Registry Repository Contributor roles to grant either registry-wide or repository-specific image permissions.

For more information on the role based on your scenario and registry role assignment permissions mode, see scenarios for ACR built-in roles. Alternatively, consult the ACR built-in roles reference for an in-depth description of each role.

Create a registry with ABAC enabled

When creating a new registry through Azure portal, select the "RBAC Registry + ABAC Repository Permissions" option in the "Role assignment permissions mode" dropdown.

Screenshot of creating a new container registry with ABAC enabled.

Continue to fill out the rest of the registry creation form, and then click "Create" to create the registry. For more information on creating a registry, see Create an Azure Container Registry using the Azure portal.

Update an existing registry to enable ABAC

To view the existing role assignment permissions mode of a registry, navigate to the registry's "Properties" blade. The current role assignment permissions mode is displayed in the "Role assignment permissions mode" field.

To update the "Role assignment permissions mode" of an existing registry, select "RBAC Registry + ABAC Repository Permissions" and click "Save" to update the registry.

Screenshot of updating an existing container registry to enable ABAC.

Assigning Microsoft Entra ABAC repository permissions

You can use either the Azure portal or Azure CLI to assign Microsoft Entra ABAC conditions to scope role assignments to specific repositories. This section provides examples of how to add ABAC conditions for a specific repository, a repository prefix (wildcard), or multiple repository prefixes (multiple wildcards).

ABAC-enabled built-in roles

The following ACR built-in roles are ABAC-enabled roles. You can specify optional ABAC conditions to the following roles to optionally scope role assignments to specific repositories.

  • Container Registry Repository Reader - ABAC-enabled role that grants permissions to read images, tags, and metadata within repositories in a registry.
  • Container Registry Repository Writer - ABAC-enabled role that grants permissions to read, write, and update images, tags, and metadata within repositories in a registry.
  • Container Registry Repository Contributor - ABAC-enabled role that grants permissions to read, write, update, and delete images, tags, and metadata within repositories in a registry.

Take note that these roles don't support catalog listing permissions to list repositories in a registry. To list all repositories in a registry (without granting permissions to read repository content), you must additionally assign the Container Registry Repository Catalog Lister role. This separate role does not support ABAC conditions and will always have permissions to list all repositories in a registry.

Important

If you assign an ABAC-enabled role without ABAC conditions, the role assignment won't be scoped to repositories. This means that a role assignment without ABAC conditions will be treated as a registry-wide role assignment, granting permissions to all repositories in the registry. To scope a role assignment to specific repositories, you must include ABAC conditions when assigning an ABAC-enabled role.

For more information on the role based on your scenario and registry role assignment permissions mode, see scenarios for ACR built-in roles. Alternatively, consult the ACR built-in roles reference for an in-depth description of each role.

Scope role assignment to a specific repository

In this example, we assign the Container Registry Repository Reader role to grant pull permissions to a single repository. By adding ABAC conditions, this role assignment lets the identity pull images, view tags, and read metadata only from the specified repository, preventing access to other repositories in the registry.

Navigate to the registry's "Access control (IAM)" blade. Click "Add" and select "Add role assignment."

Screenshot of adding a role assignment.

Select Container Registry Repository Reader as the role.

Screenshot of selecting a role to assign.

Continue by selecting the identity to assign the role to.

Afterwards, continue to the "Conditions" tab. Select the "Add condition" button to add a new ABAC condition to restrict the role assignment scope.

Screenshot of adding conditions for role assignment.

Select the "Visual" editor option in the ABAC condition builder.

Screenshot of selecting Visual editor option.

Select the actions (permissions) to grant in this repository-scoped role assignment. For most use cases, select all actions (permissions) belonging to the role you selected earlier, ensuring that identities can only perform these actions within the repository scope.

Screenshot of selecting actions and permissions to grant.

Add an expression for the ABAC condition to restrict the role assignment to a specific repository.

Screenshot of adding expression for the ABAC condition.

Configure the following options for the expression to scope the ABAC condition to a specific repository:

  • Attribute source: Request
  • Attribute: Repository name
  • Operator: StringEqualsIgnoreCase
  • Value: <repository-name> - the full name of the repository.
    • For example, if the full repository name is nginx, enter nginx.
    • If the full repository name is backend/nginx, enter backend/nginx.

Screenshot of configuring expression to scope the ABAC condition to a specific repository.

Click "Save" to save the ABAC condition.

Review the role assignment ABAC condition. The review page includes a code expression of the ABAC condition, which can be used to perform the same role assignment with the same ABAC condition using Azure CLI.

Screenshot of reviewing ABAC condition to scope to a specific repository.

Perform the role assignment by clicking "Review + assign."

Once the role assignment is created, you can view, edit, or delete the role assignment. Navigate to the registry's "Access control (IAM)" and select the "Role assignments" tab to view the list of existing role assignments that apply to the registry.

Scope role assignment to multiple repositories using repository prefix (wildcard)

In this example, we assign the Container Registry Repository Reader role to grant pull permissions to multiple repositories with a common prefix (wildcard). By adding ABAC conditions, this role assignment lets the identity pull images, view tags, and read metadata only from the repositories with a common prefix, preventing access to other repositories in the registry.

If you followed the previous example to assign the Container Registry Repository Reader role to a specific repository, you must delete that role assignment (by navigating to the "Access control (IAM)" blade and selecting the "Role assignments" tab), before creating a new one with an ABAC condition scoped to a repository prefix.

Follow the same steps as in the previous example to perform a role assignment with ABAC conditions.

In the step to add an expression for the ABAC condition, configure an expression for an ABAC condition to scope the role assignment to multiple repositories with a common prefix (wildcard). Configure the following options:

  • Attribute source: Request
  • Attribute: Repository name
  • Operator: StringStartsWithIgnoreCase
  • Value: <repository-prefix> - the prefix of the repositories, including the trailing slash /.
    • For example, to grant permissions to all repositories with the prefix backend/, such as backend/nginx and backend/redis, enter backend/.
    • To grant permissions to all repositories with the prefix frontend/js/, such as frontend/js/react and frontend/js/vue, enter frontend/js/.

Important

The trailing slash / is required in the Value field for the expression of the ABAC condition. If you don't include the trailing slash /, you may unintentionally grant permissions to other repositories that don't match the prefix. For example, if you enter backend without the trailing slash /, the role assignment grants permissions to all repositories with the prefix backend, such as backend/nginx, backend/redis, backend-infra/k8s, backend-backup/store, backend, and backendsvc/containers.

Screenshot of configuring expression to scope the ABAC condition to a repository prefix.

Click "Save" to save the ABAC condition.

Review the role assignment ABAC condition. The review page includes a code expression of the ABAC condition, which can be used to perform the same role assignment with the same ABAC condition using Azure CLI.

Screenshot of reviewing ABAC condition to scope to a repository prefix.

Perform the role assignment by clicking "Review + assign."

Once the role assignment is created, you can view, edit, or delete the role assignment. Navigate to the registry's "Access control (IAM)" and select the "Role assignments" tab to view the list of existing role assignments that apply to the registry.

Scope role assignment to multiple repositories using multiple repository prefixes (multiple wildcards)

In this example, we assign the Container Registry Repository Reader role to grant pull permissions to multiple repositories under two different prefixes (multiple wildcards). By adding ABAC conditions, this role assignment lets the identity pull images, view tags, and read metadata only from the specified repository, preventing access to other repositories in the registry.

If you followed the previous example to assign the Container Registry Repository Reader role to a specific repository, you must delete that role assignment (by navigating to the "Access control (IAM)" blade and selecting the "Role assignments" tab), before creating a new one with an ABAC condition scoped to a repository prefix.

Follow the same steps as in the previous example to perform a role assignment with ABAC conditions.

In the step to add an expression for the ABAC condition, configure two expressions to scope the role assignment to multiple repositories under two prefixes: backend/ and frontend/js/ (multiple wildcards).

For the first expression, configure the following options:

  • Attribute source: Request
  • Attribute: Repository name
  • Operator: StringStartsWithIgnoreCase
  • Value: <repository-prefix> - the prefix of the repositories, including the trailing slash /.
    • For example, to grant permissions to all repositories with the prefix backend/, such as backend/nginx and backend/redis, enter backend/.
    • To grant permissions to all repositories with the prefix frontend/js/, such as frontend/js/react and frontend/js/vue, enter frontend/js/.

Click "Add expression." Ensure that the boolean operator is set to "Or". You can optionally select "Group" to group expressions together and control the order of evaluation. The visual editor also supports multiple boolean operators including "And," "Or," hierarchical grouping, and negation.

For the second expression, configure the following options:

  • Attribute source: Request
  • Attribute: Repository name
  • Operator: StringStartsWithIgnoreCase
  • Value: <repository-prefix> - the prefix of the repositories, including the trailing slash /.
    • For example, to grant permissions to all repositories with the prefix backend/, such as backend/nginx and backend/redis, enter backend/.
    • To grant permissions to all repositories with the prefix frontend/js/, such as frontend/js/react and frontend/js/vue, enter frontend/js/.

Important

The trailing slash / is required in the Value field for the expression of the ABAC condition. If you don't include the trailing slash /, you may unintentionally grant permissions to other repositories that don't match the prefix. For example, if you enter backend without the trailing slash /, the role assignment grants permissions to all repositories with the prefix backend, such as backend/nginx, backend/redis, backend-infra/k8s, backend-backup/store, backend, and backendsvc/containers.

Screenshot of configuring expression to scope the ABAC condition to multiple repository prefixes.

Click "Save" to save the ABAC condition.

Review the role assignment ABAC condition. The review page includes a code expression of the ABAC condition, which can be used to perform the same role assignment with the same ABAC condition using Azure CLI.

Screenshot of reviewing ABAC condition to scope to multiple repository prefixes.

Perform the role assignment by clicking "Review + assign."

Once the role assignment is created, you can view, edit, or delete the role assignment. Navigate to the registry's "Access control (IAM)" and select the "Role assignments" tab to view the list of existing role assignments that apply to the registry.

Maximum number of ABAC conditions

The Azure portal supports a limited number of ABAC conditions per role assignment.

To add more than the Azure portal limit of ABAC conditions, you can use the Azure CLI to create the role assignment with more ABAC conditions.

Next steps