This topic has not yet been rated - Rate this topic

DirectoryConfiguration.Container Property

Gets or sets the name of a container defined in a storage account where the contents of file-based logs are to be transferred.

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

value = instance.Container

instance.Container = value
public string Container { get; set; }
/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public String get_Container ()

/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public void set_Container (String value)

CompilerGeneratedAttribute 
public function get Container () : String

CompilerGeneratedAttribute 
public function set Container (value : String)

Property Value

Type: System.String

Returns String.

This property specifies the name of the blob container to which a role instance’s DiagnosticMonitor will transfer diagnostics and logging data. File-based logs generated by your role are copied from their local directory to blobs within this container when a scheduled or on-demand transfer is performed. If the container does not exist, it is automatically created for you when the transfer occurs.

The Blob service endpoint is determined by the cloud storage account used to initialize the DiagnosticMonitor for the role instance.

The directory from which file-based logs are transferred is the directory defined by the Path property for this DirectoryConfiguration object.

Examples

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

// 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";

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 container name 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 = 1024;

    // 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