1

How do i create a shared access signature for Azure blobs with Access setting 'Blob(anonymous read access for blob only) '.

I came across this https://learn.microsoft.com/en-us/azure/storage/blobs/storage-dotnet-shared-access-signature-part-2 link and many links in stackoverflow. I could only see example for c# . How do i create an SAS in python ?

I have excel files present inside a blob storage and i need to access them from python

from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='name1', account_key='key1') 
blob_url = block_blob_service.make_blob_url('blob1','file1')

Now how i can access this file from blob with Access setting "Blob(anonymous read access for blob only) ?

dhinar1991
  • 831
  • 5
  • 21
  • 40

1 Answers1

1

Not fully understand what you want. Do you want to create a link with SAS for this blob?

You should first create a SAS by block_blob_service.generate_blob_shared_access_signature, and then pass this SAS to block_blob_service.make_blob_url(..., sas_token=your_generated_one)

Sraw
  • 18,892
  • 11
  • 54
  • 87
  • Thank you. I just found this 'https://stackoverflow.com/questions/41285755/how-do-you-generate-the-signature-for-an-azure-blob-storage-sas-token-in-python' . But i would like to know how long the created sas will provide access? – dhinar1991 Jul 16 '18 at 06:37
  • You can specify `expiry`. Why not read official doc? https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.baseblobservice.baseblobservice?view=azure-python#generate-blob-shared-access-signature – Sraw Jul 16 '18 at 06:39