DiagnosticMonitor.Start Method (CloudStorageAccount, DiagnosticMonitorConfiguration)

Starts a diagnostic monitor using the specified storage account and diagnostic monitor configuration.

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


Dim storageAccount As CloudStorageAccount
Dim initialConfiguration As DiagnosticMonitorConfiguration
Dim returnValue As DiagnosticMonitor

returnValue = DiagnosticMonitor.Start(storageAccount, initialConfiguration)


<EditorBrowsableAttribute(EditorBrowsableState.Advanced)> _
Public Shared Function Start ( _
    storageAccount As CloudStorageAccount, _
    initialConfiguration As DiagnosticMonitorConfiguration _
) As DiagnosticMonitor
public static DiagnosticMonitor Start (
    CloudStorageAccount storageAccount,
    DiagnosticMonitorConfiguration initialConfiguration
static DiagnosticMonitor^ Start (
    CloudStorageAccount^ storageAccount, 
    DiagnosticMonitorConfiguration^ initialConfiguration
/** @attribute EditorBrowsableAttribute(EditorBrowsableState.Advanced) */ 
public static DiagnosticMonitor Start (
    CloudStorageAccount storageAccount, 
    DiagnosticMonitorConfiguration initialConfiguration
public static function Start (
    storageAccount : CloudStorageAccount, 
    initialConfiguration : DiagnosticMonitorConfiguration
) : DiagnosticMonitor


Return Value

Type: Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor

Returns DiagnosticMonitor.


Data buffers are transferred to the specified CloudStorageAccount. The DiagnosticMonitorConfiguration object provides specific configuration options for your role instance.


If your storage account is misconfigured, your role instance will start without diagnostics. To ensure that diagnostics will start, verify that your storage account is configured correctly before calling the Start(CloudStorageAccount,DiagnosticMonitorConfiguration) method.


The following code snippet creates a DiagnosticMonitorConfiguration object, modifies the default configuration, and starts the DiagnosticMonitor by using a CloudStorageAccount:

public class WebRole : RoleEntryPoint
    public override bool OnStart()
        // Create a CloudStorageAccount object using your credentials.
        StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey(accountName, accountKey);
        CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true);

        // Create a new DiagnosticMonitorConfiguration object.
        DiagnosticMonitorConfiguration dmConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

        // Transfer the default log containers to a storage account every 30 minutes.
        dmConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);

        // Start the DiagnosticMonitor with the new DiagnosticMonitorConfiguration.
            DiagnosticMonitor.Start(storageAccount, dmConfig);
        catch (ArgumentException ae)
            // Handle any exceptions.
            System.Diagnostics.Trace.WriteLine(“Could not start the DiagnosticMonitor.” + ae.Message);

        return base.OnStart();

Thread Safety

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 and Windows Server 2008

Target Platforms

Change History

See Also


DiagnosticMonitor Class
DiagnosticMonitor Members
Microsoft.WindowsAzure.Diagnostics Namespace