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)
Syntax
public string Container { get; set; }
public:
property String^ Container {
String^ get();
void set(String^ value);
}
member Container : string with get, set
Public Property Container As String
Property Value
Type: System.String
Type: System.String
Returns String.
Remarks
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 Azure storage.
directoryConfiguration.Container = "wad-crash-dumps";
The following code snippet demonstrates how to use the Container property in the context of a remotely updating a role’s diagnostics configuration. This snippet gets the diagnostics configuration of each instance in a specific role, creates a new DirectoryConfiguration object, specifies the container name for crash dumps, and sets the new configuration.
// Get the connection string. It's recommended that you store the connection string in your web.config or app.config file.
// Use the ConfigurationManager type to retrieve your storage connection string. You can find the account name and key in
// the Azure classic portal(https://manage.windowsazure.com).
//string connectionString = "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<AccountKey>";
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
// The deployment ID and role name for your application can be obtained from the
// Azure classic portal(https://manage.windowsazure.com). See your
// application dashboard under Cloud Services.
string deploymentID = "e2ab8b6667644666ba627bdf6f5e4daa";
string roleName = "WebRole1";
// Get the DeploymentDiagnosticManager object for your deployment.
DeploymentDiagnosticManager diagManager = new DeploymentDiagnosticManager(connectionString, deploymentID);
// Get the RoleInstanceDiagnosticManager objects for each instance of your role.
IEnumerable<RoleInstanceDiagnosticManager> instanceManagers = diagManager.GetRoleInstanceDiagnosticManagersForRole(roleName);
// Iterate through the role instances and update the configuration.
foreach (RoleInstanceDiagnosticManager roleInstance in instanceManagers)
{
DiagnosticMonitorConfiguration diagnosticConfiguration = roleInstance.GetCurrentConfiguration();
// Create a new DirectoryConfiguration object.
DirectoryConfiguration directoryConfiguration = new DirectoryConfiguration();
// Add the name for the blob container in Azure storage.
directoryConfiguration.Container = "wad-crash-dumps";
// Add the directory size quota for the blob container.
directoryConfiguration.DirectoryQuotaInMB = 2048;
// 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);
// Set the configuration.
roleInstance.SetCurrentConfiguration(diagnosticConfiguration);
}
Warning
This API is not supported in Azure SDK versions 2.5 and higher. Instead, use the diagnostics.wadcfg XML configuration file. For more information, see Collect Logging Data by Using Azure Diagnostics.
See Also
DirectoryConfiguration Class
Microsoft.WindowsAzure.Diagnostics Namespace
Return to top