I am teaching Azure in England this week to Microsoft and one of my students said that he was having trouble getting an actual crash dump file to be produced, both locally and in the cloud. I think the problem was that the way you normally think to write a program that crashes is to throw an exception soon after startup. The problem is that happens every time and it doesn’t give Azure a chance to send the crash dump file. To make this work, what I wanted was a program that crashed every *other* time, allowing it to crash, then send the dump, then crash, and then send the dump, etc.

I was able to get that working successfully by creating a NumberRepository and using that to keep track of how many times I have run.  Here are some excerpts from the code:

First the OnStart of the WorkerRole:

var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
DiagnosticMonitor.Start("DiagnosticsConnectionString", config);

Then in the Run:

int number = NumberRepository.GetNumber();
if (number %2 == 1)
	throw new Exception("Bye");

I ran it one time (outside the debugger) and it crashed, I ran it again and waited for 1.5 minutes and voila it appeared in wad-crash-dumps storage container.

No comments yet.

No Comments

Sorry, the comment form is closed at this time.