Update November 2012 – See my new blog entry Debugging Azure HTTP 500 Errors. This blog no longer applies to Azure.

Using the current Azure SDK and Visual Studio 2012, you may get a HTTP 500 internal error if there is something wrong with your Web.config file.

OK, something went wrong, but what? I actually hit this error last year and blogged the solution – but a lot of changes have taken place with the Azure SDK since then, and last years solution no longer works.

By default, the ApplicationHost.config file does not enable detailed error messages. The solution I blogged last year was to edit this file and update the <httpErrors>  element and add errorMode="Detailed". But that solution no longer works. Previously the Azure compute emulator used IIS, so you could edit %windir%\System32\inetsrv\config\ApplicationHost.config and add detailed errors.  Now the Azure compute emulator uses IIS Express. Given that IIS Express by default uses stores the applicationhost.config  file in C:\Users\<user>\Documents\IISExpress\config ,  I naturally tried to update that file. It turns out that under the Azure compute emulator, IIS Express uses the applicationhost.config  file in a directory exposed with the %APPCMD% environment variable.