When Azure Diagnostics just won’t collect your data!!!

Recently realized that while we had happily implemented tracing and diagnostics in our applications , tools like Cerebrata , Azure MMC etc were just not showing any trace data.. We were doing everything by the book and even re-opened the training kit but the trace just won’t get collected. After A LOT of investigation and googling/binging it comes to light that the most optimized way of collecting diagnostics changed with Azure SDK 1.3 and further with 1.4.

If you are victim of “No WADLogsTable “ being generated try the below snippet. It just might resolve your woes

public override bool OnStart()
{
DiagnosticMonitorTraceListener tmpListener = new DiagnosticMonitorTraceListener();
System.Diagnostics.Trace.Listeners.Add(tmpListener);
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));

RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);

DiagnosticMonitorConfiguration config = roleInstanceDiagnosticManager.GetCurrentConfiguration();
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);

roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
System.Diagnostics.Trace.TraceInformation("Diagnostics Running");

return base.OnStart();
}

Do let us know if this helped!!

Cennest!

Advertisements

About Cennest
Cennest is the brainchild of a group of IT Professionals keen to try their hand in the world of IT Freelancing. After working in the corpora

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

%d bloggers like this: