I have been writing C# application where using client ID and client secret, I am trying to upload a blob to specific container on storage account. Requriement is client should only be able to upload blob to specific container and no other operation should be allowed such as creating container, deleting container, deleting blobs etc. Only one container access with List and Create needs to be given to app registration. Could anyone share setp by step approach.
I have been trying to see any policies can be defined but still could ot find way to achieve this. There is little way to control container level access on Microsoft documentation so could not achive this. Also tried looking for defining conditions in Role assignments and policies.
You can achieve this by creating an RBAC role assignment for the app registration at the container level, granting it the
Storage Blob Data Contributorrole. This will allow the app registration to perform blob-related operations on the container.Here, I first assigned the
Storage Blob Data Contributorrole for the app registration to the particular container in my storage account.Portal:
Now, using the code below, I can upload to the specific container only (test).
Code:
Output:
Now, I changed my container name to
test1and I got an error mentioning:Error:
Update:
Here you can refer this link-1 and link-2 to custom access to Azure Blob Storage using Azure role assignment conditions.