Azure Diagnostics and ASP.NET Health Monitoring

Azure Diagnostics and ASP.NET Health Monitoring

By default Windows Azure Diagnostics (WAD) does not receive ASP.NET Health Monitoring events. The machine web.config file at %windir%\Microsoft.NET\Framework64\v4.0.30319\Config\web.config shows the default behavior of ASP.NET Health Monitoring. Basically all unhandled errors and audit failures are written to the Windows Event Log within the Application folder as shown:

I’d rather use "Application!*[System/Provider/@Name[starts-with(.,'ASP.NET')]" but was unable to get the starts-with syntax to work. I’ve also noticed that events sent to DiagnosticMonitorTraceListener appear in table storage before those sent to the event log even with identical transfer periods configured. Perhaps it takes one transfer period to read from the event log and another to transfer the data?

The other approach, which I prefer, is to change the web.config so that health events are routed to the DiagnosticMonitorTraceListener as shown:

Basically this tweaks the default behavior defined in the machine’s web.config instead of completely replacing it. See the eventMappings in %windir%\Microsoft.NET\Framework64\v4.0.30319\Config\web.config to get an idea of what is possible.

When you use the event log approach your events end up in the WADWindowsEventLogsTable in Azure Storage. Modifying web.config to route health events through DiagnosticMonitorTraceListener writes the events to WADLogsTable.