Unhandled exception has occurred while running in Azure

Windows Azure, just like any other IIS website can crash if an unhandled exception occurs.  One way that this can happen is if you are calling an Async function call and in the function that is called on completion, you throw an exception.

In this situation, you will see something in the Application event log that looks like this:
     Note: you may not see both of these errors but either or both of them point to the same problem.

image

image

The way to resolve this issue is to either wrap the code inside a Try/Catch block and catch the exception or see what is causing the exception and fix that bug.  But if a block of code can throw an exception, it is always good to wrap it so that it can’t cause the entire process to crash.

The process crashing is something that started with .NET 2.0.  You can read this KB article to get more information about this and how to make it run without crashing.  There is also some more information on this on MSDN.