Saturday, May 7, 2011

Initializing Windows Azure Diagnostics- Part 1

As we have seen in my previous blog that some of diagnostics data is stored in table, while some in blob. For collecting diagnostics data, we must initialize Windows Azure diagnostic monitor. Windows Azure diagnostic monitor runs in Windows Azure and in the compute emulator and collects diagnostic data for a role instance. Only Windows Azure Logs, Windows Azure Diagnostic Infrastructure Logs and IIS logs are configured in the diagnostic monitor by default. We can collect other diagnostic data by importing diagnostic module. A role instance that imports the Diagnostic module starts, it starts the diagnostic monitor.
To start diagnostic monitor for a role open the role entry point class and make sure that you are using Microsoft.WindowsAzure.Diagnostics namespace in the class. Now on the Azure service project right click on the role and click Properties. Here I am configuring a web role.
clip_image002
Now in the configuration section check enable diagnostics. And specify the account credentials
clip_image004
You can either use development storage or can give your account credentials. Just click on “…” and will ask for the credentials.
clip_image006
Now when you open your .cscfg file it has a new setting for the webrole like
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myaccountName;AccountKey=myAccountKey" />
</ConfigurationSettings>

And in the .csdef file it import the module like:
<Imports>
<Import moduleName="Diagnostics" />
</Imports>

If you are using a web role or worker role template for creating roles then in the web.config or app.config following code is added. Or you can just inherit a class from RoleEntryPoint and add the following code in the config file.


<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>


 If you want to create a web role just override OnStart() method, and if you want to create a workerrole override OnStart() and Run() method. We will see it in my next article.

1 comment:

  1. Initializing Windows azure diagnostics- Part2
    http://reeta-singh.blogspot.com/2011/05/initializing-windows-azure-diagnostic.html

    ReplyDelete