Friday, June 7, 2013

Strange issue of Diagnostics

Issue: After upgrading Windows Azure Storage to 2.0, the diagnostics work properly when running the Azure project locally, but when deployed, the

CloudConfigurationManager.GetSetting("StorageConnectionString");

returned an empty string. The requirement was to add/ update a timestamp in one of the Azure tables on start  of the Web role. This line was a part of the code to get the connection string for the storage in which the table existed. Since it returned an empty string, the role would get recycled continuously.

Resolution: 
1. Upgrade the project
    Right-click the project, select "Properties". If it is not upgraded to Windows Azure SDK 
    2.0, VS 2012 will prompt you to upgrade to SDK 2.0. In case you have already upgraded
    the project to SDK 2.0, you will see the following screen...
   



2. Update the Microsoft.WindowsAzure.Configuration.dll
    If you have already upgraded to SDK 2.0, then the issue is that the version of the  
    Microsoft.WindowsAzure.Configuration.dll is lesser that 2.0, say 1.7 or 1.8. Just update it to 2.0 using 
    NuGet and you're set to rock 'n roll!!!

PS: Whenever you upgrade to Windows Azure SDK 2.0, make sure that all the dlls with Microsoft.WindowsAzure.* are upgraded to version 2.0
- Microsoft.WindowsAzure.Configuration
- Microsoft.WindowsAzure.Diagnostics
Microsoft.WindowsAzure.ServiceRuntime
- Microsoft.WindowsAzure.Storage (Make sure you remove  
  Microsoft.WindowsAzure.StorageClient,  which is the older version of 
  Microsoft.WindowsAzure.Storage)



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().