Since Window Azure SDK 1.3 (when the full IIS mode was made available) we have been able to deploy multiple websites in a single Web Role. We can even configure the virtual directories, applications etc. Wade Wegner has a great blog post about it (from a year ago): Running Multiple Websites in a Windows Azure Web Role
However, something must have changed in the matrix since his post or something is different from my setup than his.
If I follow his walkthrough and deploy it to Azure, everything will work fine. The issue I ran into was with getting the multiple sites running locally in order to test it before moving out to Azure. The issue shows its ugly head with this dialog:
Notice the last line in the dialog? Not sure where help is suppose to be on the dialog.
With the help of google, I found a great blog post by Michael C. Neel that got me start looking in the right direction: Debugging Azure WebRoles with Multiple Sites … though I tried the solution he walked through - it didn’t work … so I started looking though the Windows Azure Platform forums. That is where I found the answer from Fernando Tubio, which says to use the ip 127.255.0.0 when setting the host name and address in your hosts file.
After some fumbling around on my part, I got it working by making that single change. Then I when back to Michael Neel’s blog and noticed the first comment:
FYI: for some reason, I needed to use 127.255.0.0 rather than 127.255.0.1, which I thought was very strange, but whatever. I found this out by hitting F5, let the error happen, look in IIS at the generated site aliases. Select one and click Browse to see the IP it was trying to target. Then I added it in the hosts file.
Wish I would have read the comments first!
So if you are setting up a Web Role with multiple sites, make sure your entry in the C:\Windows\System32\drivers\etc\hosts file uses: 127.255.0.0 instead of 127.0.0.1.
NOTE: Also when testing it in your browser – don’t forget the port number.
My host file has an entry like this:
If I look up the sites in the IIS Admin tool (after I hit F5 in Visual Studio), I can see the site is mapped to port 82
Now I can access my second site by using the url: http://ifrdr.co:82 … otherwise if you forget the port its not going to work (even though everything is now setup ok).