Azure 1.3 added the ability to control Windows Azure Diagnostics (WAD) via a config file. The MSDN documentation covering diagnostics.wadcfg explains that the capability was added to support the VM role. The documentation also says to continue configuring WAD via code in OnStart for the other role types.
I instead recommend using diagnostics.wadcfg for all role types to perform the the majority of the configuration and only configure via code when required, such as when using a custom performance counter. This will allow WAD to capture diagnostics prior to OnStart’s execution plus it is easier to maintain a config file than code.
The documentation discusses the location Azure reads diagnostics.wadcfg from; each role type uses a different location. What isn’t explained is how to add diagnostics.wadcfg to your Visual Studio solution such that Visual Studio packages the file into the correct location. Others have blogged about this topic in sufficient detail so I’ll just say that for a web role, the hardest of the three, add an XML file to the root of your web project called diagnostics.wadcfg then change its properties so that “Build Action = Content” and “Copy to Output Directory = Copy always”. “Copy if newer” should work too but I personally prefer “Copy always”.
The sample config XML in the MSDN documentation demonstrates most of the configuration capabilities but WAD fails if the sample is copied as-is into your project. As shown below, the sample XML specifies paths and local storage names which may not exist. Comment out the entire <DataSources> element to get the configuration working. In my next blog post I’ll show how to add configuration settings for custom logs.
WAD automatically maps the wad-crash-dumps, wad-frq, and wad-iis containers to special folders which only exist in web and worker roles. For VM roles comment out the CrashDumps, FailedRequestLogs, and IISLogs elements.
Finally, there are the various “QuotaInMB” settings. WAD automatically allocates 4096 MB of local storage named DiagnosticStore. WAD fails if the overallQuotaInMB value is set higher than the local storage allocated or if the various “QuotaInMB” values add up to within about 750 MB of overallQuotaInMB. Either:
- Decrease some of the “QuotaInMB” values until the config works.
- Add a LocalStorage setting named DiagnosticStore to ServiceDefinition.csdef and increase overallQuotaInMB.
It isn’t documented but the MB’s allocated to DiagnosticStore is a hard limit which WAD can’t exceed. The various WAD quotas are soft limits which control when WAD starts deleting old data. It is possible for WAD to exceed the quotas for a brief period of time while performing the delete.
For more posts in my WAD series: