0
votes

i am storing my data to azure blobs. if the container name known, then we can access all the blobs in that container. but i need to make some authentication for accessing the blobs.

Example : set some password to access the blob while creating it.

send the password to get the blob's content.

is this possible?

code retrieve the blob without any authnetication:

       for (ListBlobItem blobItem : container.listBlobs()) {
            // If the item is a blob, not a virtual directory
            if (blobItem instanceof CloudBlockBlob) {
                // Download the text
                CloudBlockBlob retrievedBlob = (CloudBlockBlob) blobItem;
                act.outputText(view, retrievedBlob.downloadText());
            }
        }
1

1 Answers

1
votes

Blob storage supports 3 access levels - Public which enables anonymous read and listing of all the blobs in a container, Blob read - where an anonymous request can read blobs but not list the contents of the container to find others or No public access. These permissions are detailed here:

https://docs.microsoft.com/en-us/azure/storage/storage-manage-access-to-resources

For your needs I think Shared Access Signatures (SAS) would be a good bet - the article below has an example which I think should help: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-2

The SAS documentation is available here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1

Finally the article listed below has a good summary of the topic: https://www.simple-talk.com/cloud/platform-as-a-service/azure-blob-storage-part-9-shared-access-signatures/

HTH