Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read file from Azure blob storage

I want to read a PDF file bytes from azure storage, for that I have a file path.

https://hostedPath/pdf/1001_12_Jun_2012_18_39_05_594.pdf

So it possible to read content from blob storage by directly passing its Path name? Also I am using c#.

like image 933
Hope Avatar asked Jun 13 '12 11:06

Hope


1 Answers

As long as the blob is public, you can absolutely pass the blob url. For instance, you can embed it in an html image or link:

<a href="https://myaccount.blob.core.windows.net/pdf/1001_12_Jun_2012_18_39_05_594.pdf">click here</a>

By default, blob containers are private. To enable public read access, you just have to change the container permissions when creating the container. For instance:

var blobStorageClient = storageAccount.CreateCloudBlobClient();
var container = blobStorageClient.GetContainerReference("pdf");
container.CreateIfNotExist();

var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
like image 175
David Makogon Avatar answered Oct 04 '22 06:10

David Makogon