0 out of 1 rated this helpful - Rate this topic

DirectoryConfiguration.DirectoryQuotaInMB Property

Gets or sets the maximum size of the directory defined by the Path property to which file-based logs are written.

Namespace: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)
'Usage
Dim instance As DirectoryConfiguration
Dim value As Integer

value = instance.DirectoryQuotaInMB

instance.DirectoryQuotaInMB = value
public int DirectoryQuotaInMB { get; set; }
/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public int get_DirectoryQuotaInMB ()

/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public void set_DirectoryQuotaInMB (int value)

CompilerGeneratedAttribute 
public function get DirectoryQuotaInMB () : int

CompilerGeneratedAttribute 
public function set DirectoryQuotaInMB (value : int)

Property Value

Type: System.Int32

Returns Int32.

This property specifies the size of the local directory to which a role instance’s DiagnosticMonitor will store file-based diagnostics and logging data. By default, the DirectoryQuotaInMB is set to 1GB.

The size you specify for the DirectoryQuotaInMB property applies towards the OverallQuotaInMB property. Specifying a DirectoryQuotaInMB that is larger than the OverallQuotaInMB will result in an exception. If your role instance uses many logging directories, ensure that the combined size of each DirectoryQuotaInMB property is less than your OverallQuotaInMB value.

Examples

You use this property by creating a new DirectoryConfiguration object and assigning its DirectoryQuotaInMB property value:

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

// Add the directory size quota.
directoryConfiguration.DirectoryQuotaInMB = 2048;

The following code snippet shows the property in the context of a role’s OnStart() method. This method creates a new DirectoryConfiguration object, specifies the directory size for our custom log directory, adds the configuration to our DiagnosticMonitorConfiguration object, and starts the DiagnosticMonitor with the new configuration.

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

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

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

    // Add the directory size quota.
    directoryConfiguration.DirectoryQuotaInMB = 2048;

    // Add the log path for the role using RoleEnvironment.GetLocalResource().
    directoryConfiguration.Path = RoleEnvironment.GetLocalResource("MyCustomLogs").RootPath;

    // Add the directoryConfiguration to the Directories collection.
    diagnosticConfiguration.Directories.DataSources.Add(directoryConfiguration);

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

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

    return base.OnStart();
}

The following snippet from a ServiceDefinition.csdef file defines the MyCustomLogs directory.

<LocalResources>
    <LocalStorage name="MyCustomLogs" sizeInMB="8192" cleanOnRoleRecycle="false"/>
</LocalResources>

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ