Reputation: 277
I have recently started looking into using Azure but I'm having some issues getting my head around file storage. From what I've read images need to be stored as blobs and there's no way to store them directly on the file system. Unfortunately this will require a lot of modifications to our CMS which gets all its files from the file system.
When retrieving images to display on a page what is the best practice? I have played around with a few tutorials and have created a simple application which stores images and then allows you to retrieve them to display in the browser (http://www.codeproject.com/KB/cs/Azue7StepsBlob.aspx) however this retrieves an image when a button is pressed, writing out the blob stream using Image.FromStream. If you have an page with say 100 images that would require 100 separate calls to the database, is this the correct way to store and retrieve files or am I completely missing something? Any help is greatly appreciated.
Pat
Upvotes: 0
Views: 2076
Reputation: 66882
The sample you've referred to - http://www.codeproject.com/KB/cs/Azue7StepsBlob.aspx - uses Azure Blob Storage.
This is slightly different to using a SQL file store - it's not SQL, but is instead a simpler storage mechanism specialised for fast, scalable HTTP access.
When retrieving images to display on a page what is the best practice?
The "recommended way" seems to be to pass Blob store URLs direct to the browser - the browser can then retrieve and display the images - you app doesn't have to retrieve the images itself.
Depending on what your requirements are, then you can either set up public read access for the blob store or you can set up shared access signatures for temporary access. Using either of these mechanisms will allow browsers to read direct from the Blob store using HTTP.
To help understand this more, try this official tutorial - http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_exploringwindowsazurestoragevs2010_topic3.aspx
Also, take a look at other questions on here like Where to store things like user pictures using Azure? Blob Storage?
Please also be aware of the costs involved in Blob storage - there are storage costs (which are normally minimal) and also access costs - each 10000 accesses costs $0.01 - this may not sound much but could become significant if you store a lot of small frequently accessed files there.
Upvotes: 2
Reputation: 28218
You have to conceptualize the azure platform and more importantly the fact that servers will be going up and coming down.
You pay more for sql azure db usage so the most efficient method to manage images is to store the image in azure storage and keep a key pointing to that image in your sql azure database.
You will probably have to make changes regarding the architecture of your application, however you will be leveraging the power of Azure as you make these platform changes.
Upvotes: 1