Wednesday, May 8, 2013

Issue: Role instance doesn't even hit OnStart

Issue: In a Windows Azure app, some time it is seen that the role doesn't even start. On observing the VM on the Emulator, these statements are seen:


[fabric] Role Instance: deployment18(1424).PremierWorker.BackgroundWorker.0
[fabric] Role state Busy
[Diagnostics]: UpdateState(Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorStartupInfo, Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorConfiguration, )
[Diagnostics]: Acquired mutex
[Diagnostics]: Creating config channel server
[MonAgentHost] Output: Agent will exit when WADDM-ShutDown-6628f4899c2a4eeb9dc0ce93dca7aebc is signaled.
[MonAgentHost] Output: Will signal WADM-StartUp-6628f4899c2a4eeb9dc0ce93dca7aebc after the agent is initialized.
[MonAgentHost] Output: Registered as an event consumer.
[MonAgentHost] Output: Agent will exit when parent process 7544 exits.
[MonAgentHost] Output: Monitoring Agent Started
[Diagnostics]: Starting configuration channel polling
[runtime] Role entrypoint . CALLING   OnStart()
[runtime] Role entrypoint . COMPLETED OnStart()
[runtime] Role entrypoint . CALLING   Run()
[runtime] Role entrypoint . COMPLETED Run() ==> ROLE RECYCLING INITIATED
[runtime] Role instance recycling is starting
[runtime] Role entrypoint . CALLING   OnStop()
[runtime] Role entrypoint . COMPLETED OnStop()
[fabric] Role state Destroyed

Solution: After trying out everything on the net, it was finally understood that the issue was caused solely because we had upgraded from Windows Azure 1.8 to 2.0, but the Azure project wasn't upgraded.
To upgrade it, simply right-click the Azure solution, select "Properties" and then hit the Upgrade button on the screen displayed. :)

Thursday, May 2, 2013

500 Internal server error

Issue: When deploying an MVC 4, Azure based site, my team always used to get the exception "500: Internal Server Error".

Resolution: After a long time, we got the problem. The issue was in the web role on which the site was hosted. In this web role, the OnRun method was overriden, but it was empty.





Just replacing it by the following code got the issue resolved! :)






Apparently, the issue was that once the role started running, it had nothing to do and so the role would exit, hence causing the application deployed on it to crash.
Another way of taking care of this issue is to add a sleep in a while(true) statement, if you do not want to invoke the base.Run().