Loading...

Use ABAC in RBAC roles in Azure Storage to perform upload/download blobs & restrict delete blobs

Use ABAC in RBAC roles in Azure Storage to perform upload/download blobs & restrict delete blobs

Disclaimer: Please test this solution before implementing it for your critical data.

 

Scenario:

This article explains step by step procedures to accomplish the requirements in Azure Storage using built in RBAC roles:

  1. Read/Download and write/upload operation for containers and blobs should be allowed for the users.
  2. Delete operations should be restricted.

 

Pre-Requisites:

  1. Azure Storage GPV2 / ADLS Gen 2 Storage account
  2. Make sure to have enough permissions(Microsoft.Authorization/roleAssignments/write permissions) to assign roles to users , such as Owner or User Access Administrator

Action:

You could follow the steps below to create a Storage Blob Data Contributor role with conditions using the Azure portal :

 

Step 1:

  • Sign-in to the Azure portal with your credentials.
  • Go to the storage account where you could like the role to be implemented/ scoped to.
  • Select Access Control (IAM)->Add-> Add role assignment:

     

    tech01.png

Step 2:

  • In Assignment type, select Job function roles and proceed to Role.

         tech02.png

  • On the Roles tab, select (or search for) Storage Blob Data Contributor and click Next.

animeshdas11_3-1680266792680.png

  • On the Members tab, select User, group, or service principal to assign the selected role to one or more Azure AD users, groups, or service principals.
  • Click Select members.

animeshdas11_4-1680266848325.png

  • Find and select the users, groups, or service principals.
  • You can type in the Select box to search the directory for display name or email address.
  • Please continue with Step 3 to configure conditions.

 

 

 

Step 3:

The Storage Blob Data Contributor provides access to read, write and delete blobs. However, we would need to add appropriate conditions to restrict the delete operations.

  • On the Conditions (optional) tab, click Add condition. The Add role assignment condition page appears:

animeshdas11_5-1680266938728.png

 

animeshdas11_6-1680266938737.png

 

 

  •  In the Add action section, click Add action.
  • The Select an action pane appears. This pane is a filtered list of data actions based on the role assignment that will be the target of your condition. Check the box next to Delete a blob, then click Select:

animeshdas11_7-1680266938747.png

  • In the Build expression section, click Add expression. The Expression section expands.
  • Specify the following expression settings:

Setting

Value

Attribute source

Resource

Attribute

Account Name

Operator

StringEquals

Value

name_of_a_storage_account_which_doesn't_exists

 

Important:

  • Please note that this section where you configure the expression settings is very crucial and can be done in many ways. In my scenario, I selected the above values in such a way, so that the expression evaluates to false and access is not allowed to the selected action(i.e to delete a blob). Here, in my case above, I gave a random name for the Value settings i.e Account Name that doesn’t exists at all, so the expression would ideally fail and this will help to restrict delete blob operation for selected member.
  • You can go ahead and configure it as per your desire in such a way that expression can be never true.

animeshdas11_8-1680266938756.png

  • On the Review + assign tab, click Review + assign to assign the role with the condition.
  • After a few moments, the security principal is assigned the role.

Please Note

Along with the above permission, I have given the user Reader permission at the storage account  level. You could give the Reader permission at the resource level/resource group level/subscription level too.

We mainly have Management Plane and Data Plane while providing permissions to the user.

Hence, it is important that you give minimum of ‘Reader’ role at the Management plane level to test it out in Azure Portal.

 

Step 4:

Test the condition (Ensure that the authentication method is set to Azure AD User Account and not Access key)

  • Upload blobs to blob storage container successfully.

animeshdas11_9-1680267229388.png

 

  • Download/Read blobs is successful.

animeshdas11_10-1680267229408.png

 

animeshdas11_11-1680267229419.png

  • Delete blobs from blob storage container causing the below failure.

animeshdas11_12-1680267229446.png

 

 

Note: The above solution only helps in protecting deletions of blob in container and doesn’t protect against deletion of containers.

 

If you would like to add the restriction of container deletion as well, you can explore options like acquiring a lease on the container/containers along with the above implementation.

 

Please refer Lease Container (REST API) - Azure Storage | Microsoft Learn , Manage blob containers using the Azure portal - Azure Storage | Microsoft Learn for acquiring lease over the container.

 

Conclusion:

 

You can use ABAC conditions for allowing/restricting other data actions as well based on your use case scenarios.

 

 

Related documentations:

 

  1. You can also refer to the technical blog- Custom RBAC role in Azure Storage to perform upload / download operation & restrict delete operation - Microsoft Community Hub which talks about using custom role at resource group level/subscription level /management group level to perform read and write operations but restrict delete operations.
  2. What is Azure attribute-based access control (Azure ABAC)? | Microsoft Learn
  3. Azure built-in roles - Azure RBAC | Microsoft Learn
  4. Tutorial: Add a role assignment condition to restrict access to blobs using the Azure portal - Azure ABAC - Azure Storage | Microsoft Learn

 

Hope this helps!

 

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Azure Storage - TLS 1.0 and 1.1 retirement

Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...

1 year ago

Efficient Management of Append and Page Blobs Using Azure Storage Actions

  Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...

1 year ago

[Azure AI Search] Internal Server Error when creating CMK encrypted objects

Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...

1 year ago

Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#

Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...

1 year ago

Performing simple Azure Table Storage REST API operations using curl command.

The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...

1 year ago

Bulk delete all the old jobs from the batch account

Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...

1 year ago

Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases

In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...

1 year ago

[Azure Service Bus] JMS messages getting dead-lettered

The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...

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