I am using Azure Storage to save some files. I want these files to be publicly available on a temporary basis. Currently, I'm saving them via an azure storage file service. Each file is give a URL of the structure ./[file-share]/[directory]/[file-name].[ext].
My question is, is there a way to make this URL publicly available? I do not see a way. If there isn't, is there some recommended way to make a file public available? I do not see a way to do this via a file service.
Navigate to your storage account overview in the Azure portal. Under Data storage on the menu blade, select Blob containers. Select the containers for which you want to set the public access level. Use the Change access level button to display the public access settings.
A file share can be accessed via browser if the application uses REST APIs. Attachments: Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.
By default, the URL for accessing the Blob service in a storage account is https://<your account name>. blob.core.windows.net. You can map your own domain or subdomain to the Blob service for your storage account so that users can reach it using the custom domain or subdomain.
In order to download an Azure BLOB Storage item by its URL, you need to instantiate a CloudBlockBlob yourself using the item's URL: var blob = new CloudBlockBlob(new Uri(pdfFileUrl), cloudStorageAccount. Credentials); This blob can then be downloaded with the code you originally posted.
My question is, is there a way to make this URL publicly available?
One possible solution would be to create a Shared Access Signature (SAS)
on the file in question with at least Read
permission and share SAS URL with your users. You mentioned that you want the file to be publicly available on a temporary basis and for that SAS would perfectly fit the bill. You can set the SAS expiry based on your needs and once the SAS token expires, the file will no longer be available.
Other option would be to use Blob Storage
instead of File Service
. Here not only you can use Shared Access Signature but also change the container's ACL. By making the container's ACL as Blob
, the blob (file) will be publicly available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With