I’m trying to use static .html pages for a website that encounters large traffic spikes. The website is an MVC3 app. The static .html pages are in a directory structure something like the following:
approot
|---content
index.html
|---staticpages
page1.html
page2.html
page3.html
I’ve set the defaultDocument in web.config to "content/index.html". If I simply include the .html files in the project and deploy the app, it runs fine.
What we want to do is put all of the html files as blobs in a storage container. A background task (run in WebRole) checks for any updated files at a regular interval. The background task also checks to see if the .html files exist or need updating when the servers starts up. Ideally, we’d rather not have to include the .html files in the project and just grab them from storage when the server starts.
The background task pulls down the files and puts them in the proper directories just fine. However, when trying to access the website at say http://www.mysite.com, IIS returns a 403 error. If we try to access any of the other .html pages we get a 404 error. This does not occur when testing the MVC app in a local development environment.
When I turn on directory browsing in IIS, none of the files or the directories appear when getting a directory for the site. Once again using just the domain like http://www.mysite.com.
If I do include the .html files in the webrole project and then try to update one in storage, the blob is pulled from storage, but IIS serves up the old page. I’ve deleted my browser cache to be sure that wasn’t an issue. The new file is being updated correctly on the server. I’ve copied it to my local machine and looked inside it and it is indeed the updated version.
So, from what I can deduce so far it seems like Azure caches the entire website as it is deployed and doesn’t seem to allow for content change.
Is there a way to force Azure to recognize the changes or are we going to be forced to redeploy whenever there’s a change to a static .html page?
When you deploy your webrole to run on Azure, it actually packages up two copies of your Web Role. One ends up under AppRoot and one ends up under SitesRoot.
Your WebRole.OnStart processes runs in AppRoot, but your website is actually served from the copy in SitesRoot. So, the problem is that your code is happily running and copying files down from blob storage, but they are going under AppRoot so are invisible to your site.
You need to either start a thread in global.asax to do the copying or modify your code to interrogate IIS for the actual path to your web site and modify it to copy the files there. The latter is probably the safer approach.
When you run in the local emulator, everything runs from your main build directory, hence the difference in behavior.