Forum Discussion

Zer0cool114's avatar
Zer0cool114
Copper Contributor
Jan 16, 2025

how can we give access to specific folder only within blob in azure storage account container

I am trying to grant access to specific folder and its contents within a blob in a container. I have tried using ACL and SAS URLs but it gives access to whole container.

 

3 Replies

  • Zer0cool114 

    To grant access to a specific folder in an Azure Storage container:

    Use SAS Tokens:

    Generate a SAS token scoped to the folder prefix (e.g., myfolder/).
    Example: Use Azure CLI to set the --name "myfolder/*" parameter.
    Stored Access Policy:

    Attach a stored access policy to the container and generate a SAS token linked to it.
    Azure RBAC:

    Enable Azure AD and assign roles (e.g., Storage Blob Data Reader) to the folder path (mycontainer/myfolder/).
    These methods limit access to the folder and its contents.

  • Adeelaziz's avatar
    Adeelaziz
    Brass Contributor

    You can try this,

    1. Ensure your storage account has the hierarchical namespace enabled, which is required for Azure Data Lake Storage Gen2.

    2. Set ACLs on the Folder by:

    • Navigate to your storage account in the Azure portal.
    • Go to the "Containers" section and select the container that contains your folder.
    • Find the specific folder you want to set permissions for.
    • Use the "Access control (IAM)" option to assign roles at the folder level.

    3. Assign Roles:

    • Use Azure role-based access control (RBAC) to assign roles to users or groups. You can assign roles like "Storage Blob Data Reader" or "Storage Blob Data Contributor" to the specific folder.

    4. Use Shared Access Signatures (SAS):

    • Generate a SAS token with permissions scoped to the specific folder. Ensure the SAS token is configured to allow access only to the desired folder and its contents.
    • Zer0cool114's avatar
      Zer0cool114
      Copper Contributor

      Have you tested it? I did the same but still can see all the blobs within that container.

Resources