Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing Azure storage blob contents in a browser

I'm trying to find a way where I can share a SAS URL for a storage container and have it list the contents(folders and files) in a browser. Hierarchical namespace is enabled so essentially the storage account is ADLS Gen 2

A SAS url works fine if it points to a file. But the same doesn't work if I just use the url to include directory

Example:

https://<account>.blob.core.windows.net/test/test.json?.... <-- works
https://<account>.blob.core.windows.net/test?.... <-- doesn't work
https://<account>.blob.core.windows.net/test?sv=2020-10-02&st=2022-05-24T09%3A13%3A43Z&se=2022-05-25T09%3A13%3A43Z&sr=c&sp=rl&sig=H9D55HKUrw4MAkdfsdfri5k3v8%3D

with the error

Signature did not match. String to sign used was rl

SAS URL doesn't have any issues since I can connect using the storage explorer.

I tried 2 things

  1. The Azure Blob browser Chrome extension https://chrome.google.com/webstore/detail/azure-blob-browser/okdhfjbpehgfodoknombaehkhoobmefi
  2. Uploading javascript code at https://github.com/tylergibson/azure-blob-list to the root of container

The first option gave the same auth error using SAS. The second option was able to list directories and files but the problem is it lists folders as a "downloadable files". Is there a cleaner alternative to allow users to view and download storage container files from the browser?

I understand storage explorer is the way to go but just wanted to explore any alternative before giving up

like image 736
Rohini Avatar asked Oct 31 '25 10:10

Rohini


1 Answers

You'll need to do two things, so that you can list a container's contents from your browser:

First: Set up your SAS to have two permissions: Read and List. If you only add Read permissions, you can't list the contents of a container.

Next: append two additional querystring parameters to the URI you visit from within your browser:

  • restype=container
  • comp=list

So, you'd end up with something like this:

https://<acct>.blob.core.windows.net/<container>?restype=container&comp=list&sp=rl&st=2022-05-24T12:16:02Z&se=2022-05-24T20:16:02Z&spr=https&sv=2020-08-04&sr=c&sig=...
like image 123
David Makogon Avatar answered Nov 03 '25 08:11

David Makogon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!