question

simon-magrin avatar image
0 Votes"
simon-magrin asked simon-magrin commented

Azure Storage, list all blobs via REST API

Hi, I'm trying to use the REST API to read (GET) all blobs in a container, eg:

https://stackoverflow.com/questions/56774567/rest-api-to-azure-blob-storage-using-access-key

Using the 'Authorization' as 'SharedKey myaccount:blabla==' as one of two access keys, but get this auth. error. I can upload (PUT) fine.

Any tips/advice? Thanks

203076-image.png

203017-image.png

203092-image.png


azure-storage-accountsazure-blob-storage
image.png (1.2 MiB)
image.png (19.2 KiB)
image.png (24.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SumanthMarigowda-MSFT avatar image
0 Votes"
SumanthMarigowda-MSFT answered SumanthMarigowda-MSFT edited

@simon-magrin Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

I was able to repro the issue as mentioned in this article: https://docs.microsoft.com/en-us/rest/api/storageservices/list-blobs
Can you try to refer the shared key(Access key) and try again . I was able to list all the details

203135-image.png



203166-image.png

Please let us know if you have any further queries. I’m happy to assist you further.


Please do not forget to 203089-screenshot-2021-12-10-121802.png and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.



image.png (37.6 KiB)
image.png (120.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

simon-magrin avatar image
0 Votes"
simon-magrin answered simon-magrin edited

Hi @Sumarigo-MSFT, thanks for responding.

Still not working for me I'm afraid:

203139-image.png


Basically I've done the following:

  • Storage account allows my source IP address and selected VNET's

  • Querying a container that's set to Private (no anonymous access)

  • For the Params, the key's and values are defined in the 'GET' URL

  • For the Headers > 'Authorization', e.g.: 'SharedKey mystorageaccount:blablabla==' as the value

I've tried rotating the keys, disabling the firewall, including the 'x-ms-date' in the Headers as the current GMT time, specified the 'x-ms-version', and repeated these with another storage account (publicly accessible), all to no avail.


Is there something that I'm missing? Also, I can see in your Postman screenshot that you might've configured something in the [Authorization] tab perhaps? Mine is set to 'No Auth'. I can achieve the desired outcome with the Python SDK:

203197-image.png

Which regained some sanity, but for my objective and usually my first preference, I'd rather use the REST API to make this environment agnostic. Thanks!




image.png (122.0 KiB)
image.png (50.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

simon-magrin avatar image
0 Votes"
simon-magrin answered simon-magrin edited

Thanks @Sumarigo-MSFT for your help earlier, greatly appreciate it.

I got the REST API to work by unchecking the Authorization key under 'Headers' within Postman.

203180-2022-05-18-23-13-32-clipboard.png



However it only works when then the container is set to public, which isn't suitable in situations where the Storage account's containers are not publicly accessible.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.