Showing all blobs in a (foreign) container is possible with the code below, so I know the provide SAS-url is valid
from azure.storage.blob import ContainerClient, BlobServiceClient
sas_url = r'[the sas_token]'
container = ContainerClient.from_container_url(sas_url)
blob_list = container.list_blobs()
for blob in blob_list:
print(blob.name)
How do I download the contents of the container to a local folder?
With our own containers I would connect with a BlobServiceClient using the provided connection-string, which I don’t have for this container.
2
Answers
If someone else tries to save csv's from a blob here is the code is used with Gaurav's help
You are almost there. All you need to do is create
BlobClient
fromContainerClient
and blob name usingget_blob_client
method. Once you have that, you will be able to download the blob usingdownload_blob
method.Your code would be something like:
Please ensure that your SAS URL has
Read
permission otherwise download operation will fail.