Azure WorkerRole and WebRole tracing latency OnStart?
I am new to Azure development and I have been struggling in getting tracing to work (to Azure storage).
I finally managed to make it work but the first tracing messages don't seem to get transferred to the WADLogsTable.
As a wor开发者_如何学编程karoud I temporarily fixed it adding a 10s sleep after starting the DiagnosticMonitor.
I started using this in the OnStart method of a WorkerRole:
var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
now I changed it as suggested to:
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = cloudStorageAccount
.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
roleInstanceDiagnosticManager.SetCurrentConfiguration(diagnosticMonitorConfiguration);
but I am still getting the same behavior (now a sleep of 10s is not enough anymore, I had to change it to 20s).
Does anyone experience my same issues? Has anyone a better workaround? Am I doing something wrong?
This might be related to running in the local dev fabric simulator. You should try running this in an actual Windows Azure Compute instance to see if the issue goes away.
What SDK are you using? The Diagnostics Monitor from 1.3 SDK and later is running as a background task already outside of your role, so you should not call Start on it. Instead, you should configure either you the .wadcfg file or programmatically like so:
http://convective.wordpress.com/2010/12/01/configuration-changes-to-windows-azure-diagnostics-in-azure-sdk-v1-3/
Note, the blog author talks about a bug in 1.3, but that has been fixed in 1.4.
精彩评论