upgade from azure 2.4 to 2.5 now diagnostics aren't working

3.1k views Asked by At

I upgraded from azure tools 2.4 to 2.5 and now am getting a null reference thrown when I try to reference the DiagnosticMonitorConfiguration returned by DiagnosticMonitor.GetDefaultInitialConfiguration() For example

DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

will throw an exception because Directories is null. From what I've googled, the default initial config is stored in the new diagnostics.wadcfgx file, which is there and looks like

<?xml version="1.0" encoding="utf-8"?>
  <DiagnosticsConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
    <PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
  <DiagnosticMonitorConfiguration overallQuotaInMB="4096">
    <DiagnosticInfrastructureLogs />
    <Directories>
      <IISLogs containerName="wad-iis-logfiles" />
    </Directories>
    <PerformanceCounters>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
      <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Applications Running" sampleRate="PT0S" />
    </PerformanceCounters>
    <WindowsEventLog scheduledTransferPeriod="PT1M">
      <DataSource name="Application!*" />
    </WindowsEventLog>
    <Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error" />
  </DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageaccount</StorageAccount>
</PublicConfig>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<StorageAccount name="assetmanagerwms" endpoint="https://core.windows.net/" />
</PrivateConfig>
<IsEnabled>true</IsEnabled>
</DiagnosticsConfiguration>

Does anybody know what I'm missing? All properties are either null or 0 on the returned DiagnosticMonitorConfiguration.

1

There are 1 answers

0
Gaurav Mantri On BEST ANSWER

This is one of the breaking change in SDK 2.5: http://msdn.microsoft.com/en-us/library/azure/dn873976.aspx#BKMK_breaking. Essentially code based diagnostics configuration are no longer supported. From the link above:

Diagnostics configuration requires diagnostics.wadcfgx; configuration in code is no longer supported - With the Azure SDK version 2.5, all diagnostics configuration must be done in the XML configuration file diagnostics.wadcfgx, and the diagnostics agent always uses this configuration, whether it is applied through Visual Studio or Azure PowerShell. Any previous code-based diagnostics configuration (for example, using the DiagnosticMonitor API) must be migrated to the diagnostics.wadcfgx file. Code used to configure crash dumps in previous SDKs must also be migrated to the diagnostics.wadcfgx file.

If your Azure SDK version 2.4 project already uses the XML-based diagnostics configuration file diagnostics.wascfg (a recommended best practice), then when you upgrade the project in Visual Studio to target Azure SDK version 2.5, Visual Studio automatically updates the XML configuration file to the new format (diagnostics.wadcfgx). If your project continues to use a code-based configuration, then when it is upgraded to version 2.5, you will get build warnings that reference the deprecated APIs. You can use Visual Studio to configure diagnostics.wadcfgx by right-clicking a role in Solution Explorer, and then click Properties. On the Configuration tab, select Enable Diagnostics, and then click Configure. See Configuring Diagnostics for Azure Cloud Services and Virtual Machines for more information.