A day with .Net

My day to day experince in .net

Configuring Azure Diagnostic

Posted by vivekcek on April 10, 2012

The procedure for configuring azure diagnostic are.

1. Set the diagnostic connection string.

2. View the default Configuration file.

3. Change the default configuration file.

1. Set the diagnostic connection string.

In this step we will configure the the storage location for azure diagnostic data.It can be either your development storage or azure storage account.Currently i am going to use my development storage.Right click on your role select properties the select settings.Then Add Setting with Name=”Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”, Type=”ConnectionString”,and Value=”UseDevelopmentStorage=true”

Now go to WebRole.cs file and add folllowing code to start diagnostic monitor with the connection string.

public override bool OnStart()
        {
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
            return base.OnStart();
        }


2. View the default Configuration file.

On deployment a diagnostic configuration file is created in blob container named “wad-control-container”.The file name will be like (deploymentId)(RoleName)(RoleInstanceName).This will be an xml file.

<?xml version="1.0"?>
<ConfigRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <DataSources>
    <OverallQuotaInMB>4080</OverallQuotaInMB>
    <Logs>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <ScheduledTransferLogLevelFilter>Undefined</ScheduledTransferLogLevelFilter>
    </Logs>
    <DiagnosticInfrastructureLogs>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <ScheduledTransferLogLevelFilter>Undefined</ScheduledTransferLogLevelFilter>
    </DiagnosticInfrastructureLogs>
    <PerformanceCounters>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <Subscriptions />
    </PerformanceCounters>
    <WindowsEventLog>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <Subscriptions />
      <ScheduledTransferLogLevelFilter>Undefined</ScheduledTransferLogLevelFilter>
    </WindowsEventLog>
    <Directories>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <Subscriptions>
        <DirectoryConfiguration>
          <Path>c:\dftemp\Resources\2cd3f044-03f6-481c-8868-b1b0ee2ca957\directory\DiagnosticStore\FailedReqLogFiles</Path>
          <Container>wad-iis-failedreqlogfiles</Container>
          <DirectoryQuotaInMB>1024</DirectoryQuotaInMB>
        </DirectoryConfiguration>
        <DirectoryConfiguration>
          <Path>c:\dftemp\Resources\2cd3f044-03f6-481c-8868-b1b0ee2ca957\directory\DiagnosticStore\LogFiles</Path>
          <Container>wad-iis-logfiles</Container>
          <DirectoryQuotaInMB>1024</DirectoryQuotaInMB>
        </DirectoryConfiguration>
        <DirectoryConfiguration>
          <Path>c:\dftemp\Resources\2cd3f044-03f6-481c-8868-b1b0ee2ca957\directory\DiagnosticStore\CrashDumps</Path>
          <Container>wad-crash-dumps</Container>
          <DirectoryQuotaInMB>1024</DirectoryQuotaInMB>
        </DirectoryConfiguration>
      </Subscriptions>
    </Directories>
  </DataSources>
  <IsDefault>false</IsDefault>
</ConfigRequest>

You can use the ‘Azure Storage Explorer Tool’ from codeplex to see this blob file.

3. Change the default configuration file.

Consider that you want to change the diagnostic settings for ‘Windows Azure Infrastructure Logs’.In the configuration file the default settings for infrastructure log is

    <DiagnosticInfrastructureLogs>
      <BufferQuotaInMB>0</BufferQuotaInMB>
      <ScheduledTransferPeriodInMinutes>0</ScheduledTransferPeriodInMinutes>
      <ScheduledTransferLogLevelFilter>Undefined</ScheduledTransferLogLevelFilter>
    </DiagnosticInfrastructureLogs>
    

Now if you want to set the ScheduledTransferPeriod you can change this tag.Diagnostic Monitor will catch the configuration change

and apply new changes immediately(Diagnostic Monitor polls for the configuration changes).The same things can be done via code also.If we are using code to change the

default configuration we don’t need to directly edit the file in wad-control-container.The code will over write the config file.

var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
            config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString",config);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s