Migrate static content from ASP.NET project to Windows Azure platform

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

Upvotes: 0

Views: 676

Answers (3)

Brian Reischl
Brian Reischl

Reputation: 7356

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.

Upvotes: 0

David Makogon
David Makogon

Reputation: 71055

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.

Upvotes: 1

BrentDaCodeMonkey
BrentDaCodeMonkey

Reputation: 5513

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.

Upvotes: 1

Related Questions