Loading...

How to control access to identity-specific folders in Azure Blob Storage using ABAC

How to control access to identity-specific folders in Azure Blob Storage using ABAC

An example use case: 

 

I have an Azure Blob Container named "my-org-documents"; a specific folder should be shared across all the identities. However, each identity can only write into their subfolders. 

 

I will use the below identities as example: 

 

[email protected] (AD user) 

ExampleMI12 (managed identity)

 

I have created a path called test, managedidentity and sharedfolder under the container, so the structure is as below: 

 

my-org-documents/test

my-org-documents/managedidentity

my-org-documents/sharedfolder

 

My task is completed when: 

 

- Active Directory user "test" is able to read/write into sharedfolder

- Active Directory user "test" is able to read/write into test folder but not into managedidentity folder. 

- Managed Identity "ExampleMI12" is able to read/write into sharedfolder

- Managed Identity "ExampleMI12" is able to read/write into "ExampleMI12" folder but not into test folder. 

 

Scoping the role assignment: 

 

In such scenario, you can achieve the target by assigning "Storage Blob Data Contributor" to the required identity while applying ABAC conditions to add more control over folder access. 

 

Configuring the user permissions: 

 

 - Assigning "Storage Data Contributor role" to user "test" on the storage account level. 

 

mahmoudsamy_2-1676793558879.png

 

-Then, in the conditions tab, I will add the below policy: 

 

 

 

 

 

 

 

 

( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'} AND NOT SubOperationMatches{'Blob.List'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder/' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'test/' ) ) ) AND ( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/delete'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'test/' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder/' ) ) )

 

 

 

 

 

 

 

 

 

The above ABAC policy will only allow read/write access to "test" and "sharedfolder" paths, while it will deny access to all the other folders inside the "my-org-document" container or any other container inside the storage account. 

 

 

Configuring the managed identity permissions: 

 

 - Assigning "Storage Data Contributor role" to managed identity "ExampleMI12" on the storage account level. 

 

 

- Then, in the conditions tab, I will add the below policy: 

 

 

 

 

 

 

 

 

 

( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'} AND NOT SubOperationMatches{'Blob.List'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder/' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'managedidentity/' ) ) ) AND ( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/delete'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'managedidentity/' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder/' ) ) )

 

 

 

 

 

 

 

 

 

Conclusion

 

In this scenario, I was able to control folder level access for AD identities by assigning a role to each identity while adding specific ABAC conditions that will add more granularity over the wide role access. 

 

 

 

Note: For ADLS endpoint, the ABAC policy should be modified to remove the ending slash from the blob path. Similar to the below example:

 

 

 

 

 

 

 

( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'} AND NOT SubOperationMatches{'Blob.List'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'test' ) ) ) AND ( ( !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action'}) AND !(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/delete'}) ) OR ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'my-org-documents' AND ( @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'test' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringStartsWith 'sharedfolder' ) ) )

 

 

 

 

 

 

 

Note:

Please add "microsoft.storage/storageAccounts/blobServices/containers/blobs/runAsSuperUser/action" action on all conditions if:

 

1- The role definition contains this action, such as "Storage blob data owner"

2- The storage accounts included in this condition have hierarchical namespace enabled or might be enabled in the future.

 

 

 

 

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Transforming Field Operations with AI, Azure Maps & Dynamics 365

Efficient field operations are the backbone of successful, data-driven organizations. Yet, many businesses continue to struggle with scattered...

1 day ago

Failures Happen in Cloud, but how Azure Cosmos DB keeps your Applications Online

The only thing that’s constant in distributed systems is failures. No cloud platform is immune to failures — from regional outages and transie...

3 days ago

The `azd` extension to configure GitHub Copilot coding agent integration with Azure

This post shares how to set up the GitHub Copilot coding agent integration with Azure resources and services by using the Azure Developer CLI ...

3 days ago

Announcing Azure MCP Server 1.0.0 Stable Release – A New Era for Agentic Workflows

Today marks a major milestone for agentic development on Azure: the stable release of the Azure MCP Server 1.0! The post Announcing Azure MCP ...

5 days ago

From Backup to Discovery: Veeam’s Search Engine Powered by Azure Cosmos DB

This article was co-authored by Zack Rossman, Staff Software Engineer, Veeam; Ashlie Martinez, Staff Software Engineer, Veeam; and James Nguye...

5 days ago

Azure SDK Release (October 2025)

Azure SDK releases every month. In this post, you'll find this month's highlights and release notes. The post Azure SDK Release (October 2025)...

6 days ago

Microsoft Copilot (Microsoft 365): [Copilot Extensibility] No-Code Publishing for Azure AI Foundry Agents to Microsoft 365 Copilot Agent Store

Developers can now publish Azure AI Foundry Agents directly to the Microsoft 365 Copilot Agent Store with a simplified, no-code experience. Pr...

6 days ago

Azure Marketplace and AppSource: A Unified AI Apps and Agents Marketplace

The Microsoft AI Apps and Agents Marketplace is set to transform how businesses discover, purchase, and deploy AI-powered solutions. This new ...

9 days ago

Episode 413 – Simplifying Azure Files with a new file share-centric management model

Welcome to Episode 413 of the Microsoft Cloud IT Pro Podcast. Microsoft has introduced a new file share-centric management model for Azure Fil...

10 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy