1

I've got a website that will need to access a file on the file system (or somewhere) containing some template text used to send an email. I'd like a suggestion for where to store the file and how to access / find the file at runtime for both azure web roles and azure web sites.

So far, I've read about Azure Local Storage, but that seems to only be an option for web roles, and not available for azure websites (I think?). Plus, I'm not sure how the file would make its way into the storage.

The other option I was thinking about was adding the file to the VS solution and marking it as content, in which case I believe it would be deployed with the other files. But in this case, I don't know how to get the path to access the file form the .NET code. Also, with this, I believe that I would need to redeploy the entire solution in order to update the file.

I would appreciate any thoughts on this. Thanks...

BenjiFB
  • 4,545
  • 10
  • 46
  • 53
  • You could probably use blob storage to store the file and download it from there and store locally as and when needed. – Gaurav Mantri Dec 01 '14 at 03:51
  • As Gaurav mentioned put it on a Azure Storage initially and download locally when needed as mentioned here: http://stackoverflow.com/questions/20615289/where-to-save-extract-files-on-azure-web-sites – Sri Kanth Dec 01 '14 at 03:59
  • But wouldn't it be accessible more quickly (and potentially more efficiently) if stored locally on the file system? – BenjiFB Dec 01 '14 at 04:36

1 Answers1

3

Using a non-local storage system is your best approach, it is highly unlikely your speed requirements will be that intense it will need intense performance improvements.

I would recommend blob storage in the same region as your website/cloud service.

If you have extreme loads and need that file loaded rapidly, then have an in-memory cache set to 5 minutes or something low to store the template. Each time it checks the cache, if its not there it loads in the cache from storage then provides the resource.

You may look at using cache if you are getting a constant 1 request per second or higher. Anything lower than that then just stick to reading on demand directly from the blob storage.

If you really want to get something locally off the disk then do

Server.MapPath("~/YourFolder/YourFile.ext")
Adam
  • 16,089
  • 6
  • 66
  • 109
  • Thanks for the insight. Out of curiosity, then, when (in your opinion) should one use Azure local storage? http://msdn.microsoft.com/en-us/library/azure/ee758708.aspx – BenjiFB Dec 01 '14 at 12:58
  • And can you give a brief idea of a strategy for implementing the in-memory caching system you suggest? – BenjiFB Dec 01 '14 at 13:00
  • Looks like this is an example of how to cache for web api: http://stackoverflow.com/questions/18937545/caching-application-data-in-memory-mvc-web-api – BenjiFB Dec 01 '14 at 13:29
  • This is a good example of in memory caching: http://dotnet.dzone.com/articles/memory-cache-implementation-c – Adam Dec 01 '14 at 14:18
  • 1
    Local Storage would mainly be used for temporary working files. Local storage is per instance only and hence only normally used for startup tasks or a space for working files if there is a long running process or something similar on that instance but doesn't need to talk to any other instance in the process. – Adam Dec 01 '14 at 14:20