joepetrakovich
joepetrakovich

Reputation: 1366

What should I be saving locally when I use Azure blob storage?

I'm using Azure Blob Storage to allow users to upload files from a web app.

I've got them uploading into a container, but I'm not sure what would be best to save on the web app's database since there are multiple options.

There is a GUID for the file, but also a URL.

The URL can be used to get to the file directly, but is there a risk that it could change?

If I store the file GUID I can use that to get the other details of the file using an API, but of course that's and extra step compared to the URL.

I'm wondering what best practices are. Do you just store the URL and be done with it? Do you store the GUID and always make an extra call whenever a page loads to get the current URL? Do you store both? Is the URL something constant that can act just as good as a GUID?

Any suggestions are appreciated!

Upvotes: 0

Views: 125

Answers (1)

Zeeshan
Zeeshan

Reputation: 506

If you upload any file on azure blob it will give you Url to access it which contains three part

         {blob base url}/{Container Name}/{File Name}

e.g

https://storagesamples.blob.core.windows.net/sample-container/logfile.txt

SO you can save Blob base url and container name in config file and only the file name part in data base.

and at run time you can create whole url and return it back to user.

So in case if you are changing blob or container you just need to change it in config file.

Upvotes: 2

Related Questions