Uploading Crash Dump from Azure VM to Windows Azure Storage using Diagnostics Monitor Agent

Windows Azure SDK 1.4
you can use the following code in Web Role or
Worker Role to Add :


        public override bool OnStart()
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
//We need to get default initial configuration
var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
//Windows Azure Logs. Table: WADLogsTable
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
config.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(5);
//Performance counters. Table: WADPerformanceCountersTable
new PerformanceCounterConfiguration
CounterSpecifier = @"\Processor(*)\*",
SampleRate = TimeSpan.FromSeconds(1)
config.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromSeconds(5);
//You can add more performance counter using the link below:
// - http://blogs.msdn.com/b/avkashchauhan/archive/2011/04/01/list-of-performance-counters-for-windows-azure-web-roles.aspx?wa=wsignin1.0
//Windows Azure Diagnostic Infrastructure Logs. Table: WADDiagnosticInfrastructureLogsTable
config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromSeconds(5);

//Windows Event Logs. Table: WADWindowsEventLogsTable
config.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
config.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromSeconds(5);
//Crash Dumps. Blob. Container: wad-crash-dumps
//Custom Error Logs
var localResource = RoleEnvironment.GetLocalResource("ErrorStorageFolder"); // ErrorStroageFolder is the Local Storage you will have to add with You Role
var directoryConfiguration = new DirectoryConfiguration
Container = "wad-custom-log-container",
DirectoryQuotaInMB = localResource.MaximumSizeInMegabytes,
Path = localResource.RootPath
config.Directories.BufferQuotaInMB = 1024;
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);//for crash dumps and custom error log
// Based on above code, you can verify that you have setup dump data transfer time to 1 minutes.

//Start with new configuration
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
//Adding 10 seconds time so crash dumps can be uploaded. You can find a suitable time depend on your test to upload the crash dumps.
return base.OnStart();



Verification  on
Windows Azure VM:

You can
verify that infrastructure log are created in Windows Azure VM at location


crash dumps will be located at folder bellow:


You can
also look at the Monitoring Host configuration file for the role and verify the
transfer time is set as below:






<Path>********** Role Path **************** </Path>






Further Analysis:

Once the crash will occur the
role will die and upload will be scheduled during next role startup. Based on
above, the crash dump will be uploaded next time your role starts up, and it
will take some time for the uploading. If your role only runs for a short time
after the crash, then Diagnostics may  not have enough time for the
uploading. That's why we have added Thread.Sleep() in the above code to give
enough time to upload the crash dumps when created.

Here is how it works:

Role starts and then
crash happens due to any reason during start

The crash dump was
created immediately

This crash cause
application to exit

When App Agent
starts the role again the crash dump is being uploaded however if time is very
less to upload and the upload action is broken and crash dumps cannot be

Adding some sleep
time in the same thread solves this crash dump upload issue


Comments (0)

Skip to main content