Export (0) Print
Expand All

CrashDumps.EnableCollectionToDirectory Method

Updated: June 6, 2012

Enables collection mini crash dumps or full crash dumps for a role instance to the specified directory.

Namespace: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)

public static void EnableCollectionToDirectory (
	string directory,
	bool enableFullDumps



Type: System.String

The absolute path to the local directory.


Type: System.Boolean

If true, collects full crash dumps. If false, collects mini crash dumps.

When you enable collection of crash dumps, the resulting data is written locally to the specified directory.

When crash dump data is transferred to persistent storage, it is stored to the wad-crash-dumps Blob container. You can specify the transfer interval of the specified directory by setting the ScheduledTransferPeriod property of Directories.


You can create a local resource for your hosted service by adding a LocalResources element to the ServiceDefinition.csdef file. For example, the following sample creates a local resource called MyCustomCrashDumpsLocation:


<ServiceDefinition name="MyServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole1" vmsize="Small"> 
      <LocalStorage name="MyCustomCrashDumpsLocation" sizeInMB="1024" cleanOnRoleRecycle="false" />

The following code snippet creates a DiagnosticMonitorConfiguration object, enables full crash dump collection to the MyCustomCrashDumpsLocation resource, adds the path to the list of directories that are monitored for diagnostic data, and sets a transfer interval of 30 minutes.


public override bool OnStart()
    // Get the default initial configuration for DiagnosticMonitor.
    DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

    // Create a custom logging path for crash dumps.
    string customCrashDumpsPath = RoleEnvironment.GetLocalResource("MyCustomCrashDumpsLocation").RootPath;

    // Enable full crash dump collection to the custom path.
    CrashDumps.EnableCollectionToDirectory(customCrashDumpsPath, true);

    // Create a new DirectoryConfiguration object.
    DirectoryConfiguration directoryConfiguration = new DirectoryConfiguration();

    // Add the name for the blob container in Windows Azure storage.
    directoryConfiguration.Container = "wad-crash-dumps";

    // Add the directory size quota.
    directoryConfiguration.DirectoryQuotaInMB = RoleEnvironment.GetLocalResource("MyCustomCrashDumpsLocation").MaximumSizeInMegabytes;

    // Add the crash dumps path.
    directoryConfiguration.Path = customCrashDumpsPath;

    // Schedule a transfer period of 30 minutes.
    diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);

    // Add the directoryConfiguration to the Directories collection.

    // Start the DiagnosticMonitor using the diagnosticConfig and our connection string.
    DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);

    return base.OnStart();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

Community Additions

© 2015 Microsoft