0

I've got asp.net project. I want publish it in azure platform. My project contains different static content: images, javascript, css, html pages and so on. I want store this content in azure blob storage. So, my questions are: 1) Is there any way to automate the process of migration this content from my application to blob storage? 2) How can I use data retreived from blob storage? Any examples would be great!

Best regards, Alexander

3 Answers3

1

First off, what you're trying to do could create cross-site scripting (they'll be on different domain names) or security issues (if you're using SSL). So make sure you really want to seperate the static files from the rest of your web site.

That said, the simpliest approach would be to use any one of a number of Windows Azure Storage management utilities (Storage Explorer or Cerebrata's Storage Studio would both work), to upload the static content to a Windows Azure Storage blob container. Then set the permissions on that container to publis read so that anyone with a web browser can access the contents of the container.

Finally, change all referrences to the content to point to the new URI's in blob storage and deploy your ASP.NET web role.

Again though, if I were you, I'd really look at what you're trying to accomplish with this approach. By putting it in blob storage, you do gain access to a few things (like CDN enablement), but as a trade-off, you lose control over many others (like simplified access control via IIS for request logs to tell when someone is downloading your image files a trillion times to try and run up your bill). So unless there's a solid NEED for this, I'd generally recommend against it.

BrentDaCodeMonkey
  • 5,493
  • 20
  • 18
  • Thanks for your reply! I need store static content in blobs because of simplicity update. For example I need update picture in aspx form. Insted of update whole site I'll find this picture in blob and just substitute it. – Александр Сысоев Apr 10 '12 at 12:43
  • What's nice is that Storage Analytics will give you traceability when it comes to Blob access, via `$logs`. You can read more about analytics [here](http://blogs.msdn.com/b/windowsazure/archive/2011/08/03/announcing-windows-azure-storage-analytics.aspx) – David Makogon Apr 10 '12 at 12:43
1

Adding a bit to @Brent's answer: you'll get a few more benefits when offloading static content to blob storage, such as reduction in load against your Web Role instances.

I wrote up a more detailed answer on this similar StackOverflow question.

Community
  • 1
  • 1
David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • Can you please tell me storing content in blobs and CDN is the same? – Александр Сысоев Apr 10 '12 at 13:12
  • The actual procedure & location for storing, from your perspective, is the same. You just need to activate the CDN for the storage account holding your static content, then change the URL's to point to the "CDN" version of the URL (based on the CDN namespace you create). At that point, your content will be loaded into one or more CDN nodes as needed and then served from there. Note: You have no ability to force an expiration for an object. If you set the TTL of a JPG to, say, 24 hours, then upload a new JPG 5 hours later, your end users won't see the update for 19 more hours. – David Makogon Apr 10 '12 at 15:09
0

In light of your comment to Brent, you may want to consider uploading the content into Blob storage and then proxying it through a WebRole. You can use something like an HttpModule to accomplish that fairly seamlessly.

This has 2 main advantages:

  1. You can add/modify files without reloading your web roles or losing them on role refresh.
  2. If you're migrating a site, the files can stay at the same URLs they were pre-migration.

The disadvantages:

  1. You're paying the monetary cost for Blob accesses and the performance cost to your web roles.
  2. You can't use the Azure CDN.
  3. Blob storage is generally slower (higher latency) than disk access.

I've got a fairly simple module I wrote to do exactly this. I haven't gotten around to posting it anywhere public, but if you're going to do this I can send you the code or something.

Brian Reischl
  • 7,216
  • 2
  • 35
  • 46
  • You could take you approach and go a step further by caching the static content in localstorage within each instance. This reduces the continued hits against Azure Storage for frequently accessed files as well as the latency. If you put this cache into a writeable (to the applicaion) area under the web apps root you can even avoid needing to use the HttpModule. :) – BrentDaCodeMonkey Apr 10 '12 at 21:58
  • You could, but if the blobs are being updated then you also have to deal with cache coherency issues. I wussed out and did it the easy way instead. :) But if you wanted to be really clever you could run a background process/thread to do conditional updates on all the localstorage files every so often. – Brian Reischl Apr 11 '12 at 01:00
  • Yes, could you please send me your module on my email asysoev@list.ru – Александр Сысоев Apr 11 '12 at 08:15