This post will describe how to troubleshoot an Internal Server Error 500 in an Azure webrole. This is a continuation of the troubleshooting series.
Symptom
You have deployed your WebRole, which works perfectly fine on your development machine, to Windows Azure and it shows as Ready in the portal, but when you browse to the site you get:
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Troubleshooting
If the role itself is showing Ready in the portal, but there are functional issues with your hosted service (ie. this 500 Internal Server Error) then the first and easiest step is to RDP to the Azure VM and attempt to browse to the site using the DIP. The DIP is the VM’s internal IP address (a 10.xxx or 100.xxx address) which you can get from ipconfig or IIS Manager. This will give you the more detailed error information that you would expect to get when browsing a website from the server where IIS is running. Typically the error and root cause of the issue will be immediately apparent.
The easiest way to browse the website on the local DIP is to open IIS Manager, expand Sites and click on the website. On the right-hand side you will see ‘Browse Website’. Alternatively you can use ipconfig to get the local IP address and then open Internet Explorer and browse to that address, but if your site is not on the standard port 80 you will also have to find the port number. You can get the port number from IIS Manager, the management portal, or your .csdef file, but in general it is just easier to browse directly using IIS Manager.
Browsing to the local DIP in IE will result in more detailed error information:
In this case we can see the following problem:
Error Code
0x80070032
Config Error
The configuration section ‘system.web.webPages.razor’ cannot be read because it is missing a section declaration
Solution
This particular problem can be resolved by adding the razor sectionGroup settings to your web.config file. But more generically this blog post is meant to show you how to get the detailed error information, which at that point should be easy enough to do a quick web search to find a solution.