4
votes

I'm trying to understand the various ways to configure the Diagnostics in Windows Azure. So far I've set a diagnostics.wadcfg that is properly used by Azure as I retrieve its content in the xml blob stored by Diagnostics in the wad-control-container (and the tables are updated at the correct refresh rate).

Now I would like to override some fields from the cscfg, in order to boost the log transfer period for all instances, for example (without having to update each wad-control-container file, which will be erased in case of instance recycle btw). So in my WebRole.Run(), I get a parameter from RoleEnvironment.GetConfigurationSettingValue() and try to apply it to the current config ; but my problem is that the values I read from DiagnosticMonitor.GetDefaultInitialConfiguration() do not correspond to the content of my diagnostics.wadcfg, and setting new values in there doesn't seem to have any effect.

Can anyone explain the relationship between what's taken from diagnostics.wadcfg and the values you can set at run-time?

Thanks

3

3 Answers

3
votes

GetDefaultInitialConfiguration() will not return you your current settings, becasue as its name states it takes a default configuration. You have to use the GetCurrentConfiguration method if you need to take the configuration that is in place.

However, if you need to just boost the transfer, you could use for example the Cerebrata's Azure Diagnostics Manager to quickly kick off on-demand transfer of your roles.

You could also use the Windows Azure Diagnostics Management cmdlets for powershell. Check out this article.

Hope this helps!

2
votes

In order to utilize values in wadcfg file the following code code could be used to access current DiagnosticsMonitorConfiguration:

var cloudStorageAccount = CloudStorageAccount.Parse(
            RoleEnvironment.GetConfigurationSettingValue(WADStorageConnectionString));
var roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
            RoleEnvironment.DeploymentId,
            RoleEnvironment.CurrentRoleInstance.Role.Name,
            RoleEnvironment.CurrentRoleInstance.Id);
var dmc = roleInstanceDiagnosticManager.GetCurrentConfiguration();
// Set different logging settings
dmc.Logs....
dmc.PerformanceCounters....
// don't forget to update
roleInstanceDiagnosticManager.SetCurrentConfiguration(dmc);
0
votes

The code by Boris Lipshitz doesn't work now (Breaking Changes in Windows Azure Diagnostics (SDK 2.0)): "the DeploymentDiagnosticManager constructor now accepts a connection string to the storage account instead of a CloudStorageAccount object".

Updated code for SDK 2.0+:

    var roleInstanceDiagnosticManager = new RoleInstanceDiagnosticManager(
// Add StorageConnectionString to your role settings for this to work
                CloudConfigurationManager.GetSetting("StorageConnectionString"), 
                RoleEnvironment.DeploymentId,
                RoleEnvironment.CurrentRoleInstance.Role.Name,
                RoleEnvironment.CurrentRoleInstance.Id);
    var dmc = roleInstanceDiagnosticManager.GetCurrentConfiguration();
    // Set different logging settings
    dmc.Logs....
    dmc.PerformanceCounters....
    // don't forget to update
    roleInstanceDiagnosticManager.SetCurrentConfiguration(dmc)