ACLs in Azure Data Lake Gen2 - Replacing User Entities with an AAD Security Group
Azure Data Lake Storage (ADLS) Gen2 is a highly scalable and secure data storage service. It is a fundamental solution for our Data Analytics infrastructure in Azure. ADSL Gen2 implements access control based on both Azure RBAC and POSIX-li
AI-assisted translation, approved by Mateo.


Azure Data Lake Storage (ADLS) Gen2 is a highly scalable and secure data storage service. It is a fundamental solution for our Data Analytics infrastructure in Azure. ADSL Gen2 implements access control based on both Azure RBAC and POSIX-like Access Control Lists (ACLs).
What are ACLs?
Access Control Lists, as their name indicates, represent rules for managing access to a DataLake's directories or Blobs. They allow us to define access permissions for blobs. For example, you could have an ACL for a directory that specifies that one user has read permissions, a user group has write permissions, and an application has execute permissions. Using ACLs enables granular access control over stored data.
Entries, Entities, and Security principals
In ADLS, permissions can be assigned to 'Security Principals', which are objects that represent a user, group, 'service principal', or a 'managed identity' in Azure RBAC. In the context of ACL administration, these 'security principals' are referred to as 'entities', referring to any object that can be assigned permissions. Assigning a specific access level to an entity in an ACL is known as an 'entry'."

ACL Types
There are 2 types:
- Access ACLs: indicate access to an object.
- Default ACLs: are templates associated with a directory and determine access for subsequent directories below their level. They are associated with every directory that is created. They do not apply at the file level.
Permission Levels
Permissions are based on the POSIX (Portable Operating System Interface) permission system. There are three basic types of permissions:
- Read (r): For a file, read permission allows you to view the file's contents. For a directory, it allows you to see which files and subdirectories it contains, but not necessarily to view the contents of those files or subdirectories.
- Write (w): For a file, write permission allows you to modify the file's contents. For a directory, it allows you to add, modify, or delete files and subdirectories, but it does not grant read or execute permissions.
- Execute (x): This permission allows an entity to execute a file or access the files in a directory. For a file, execute permission allows the file to be run as a program. For a directory, it allows access to files and subdirectories, but does not grant read or write permissions.
These permissions can be assigned to three different types of entities:
- A "Super-User" has the broadest rights, including RWX permissions for all files and folders, and can change the permissions, owner user, and owner group of any file or folder.
- The "Owner User" is the person who created the item and has the right to change the permissions and owner group of a file they own, as long as the owner user is also a member of the target group.
- The "Group User" behaves similarly to permissions assigned to other users or groups and can be changed by any super-user or by the owner user if they are also a member of the target group.}
- The "Mask" entry is used to specify the maximum permissions that can be assigned to a user or group. It is a set of permissions that acts as a filter, controlling which permissions are allowed and which are denied for the users and groups specified in the ACL.
Identities are evaluated in the following order:
- Super-User,
- User Owner,
- Entities (user or group),
- Group Owner,
- All other users.
If an identity has multiple roles, the permission level associated with the first identity evaluated is applied.

In the list, we can see these default permissions and only 1 entity (group) with full permissions.
Permission Inheritance
In ADLS Gen2, permissions must be explicitly set for each file and directory. Although we can define permissions at the directory level, they will not automatically be inherited by the subdirectories and files within that directory. For example, if you give a group read permissions on a specific directory, that group will not automatically have read permissions for all the files and subdirectories within that directory. You would have to explicitly grant those permissions for each subdirectory and file.
For these permissions to be inherited by subdirectories, we must propagate them. ADLS Gen2 offers the option of setting permissions recursively. This means that in a single operation we can apply permissions to a directory and all its subdirectories and files. If a file or directory already has a permission set, applying permissions recursively will not change the existing permissions.
ACL Entity Limits
ACLs can have a maximum of 32 entities. Of the total, 28 are ACL entities.
Best Practices: use security groups
One of the most important recommendations is to use security groups instead of users. It is VERY IMPORTANT to resist assigning permissions directly to users. This gives us 2 advantages:
- We can grant permissions without needing to recursively reapply ACLs to an entire directory.
- We avoid filling our ACLs and reaching the maximum number of entries.
What happens if we fill the ACL of a root directory?
If we reach the maximum limit of 32 entries, we will not be able to assign additional permissions in this directory or in all its subdirectories if the ACL is propagated (which is usually the most common case). For this, we can use the following GitHub repository:

https://github.com/mdiloreto/AzureDataLake_ACL-User_Entity_to_AADGroup-Scripts
Here we present a collection of scripts designed to recursively manage our ACLs using PowerShell. In particular, the script "02-ReplaceRecursivo_ACLentitys-with-ADSecGroup-v2.ps1" is designed to replace all our ACL entities of type 'User' with a certain permission level, removing them from the ACL, adding them to an Azure AD (AAD) security group, and then assigning the same permissions to that AD group in the ACL.
I also designed a Rollback script "03-RollbackRecursivo-Grant-ACL-from-csv.ps1" that will allow us, after exporting an ACL to CSV, to recursively reassign the permissions "as they were" to another ACL.
Thanks for reading. The learning continues in the next article.


