DirectoryConfiguration.Container Property
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)
/** @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.StringReturns 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>
Development Platforms
Windows Vista, Windows 7 and Windows Server 2008Target Platforms