Reputation: 1852
Azure is starting to do my nut, I am trying to get diagnostics tracing working and have followed various guides (all pretty much say the same thing). I now can't debug locally (I get errors) and RDP doesn't seem to want to connect. I have the following in the web config:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
And then this in the webrole.cs:
public override bool OnStart()
{
var diagnostics = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnostics.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
diagnostics.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
diagnostics.Logs.BufferQuotaInMB = 10;
CloudStorageAccount account = CloudStorageAccount.Parse(
RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"));
DiagnosticMonitor.Start(account, diagnostics);
return base.OnStart();
}
And this in the service definition file:
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
</Imports>
And this in the service config file:
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<snip>;AccountKey=<snip>" />
I don't get any errors when the site is deployed, I tried a text listener locally which worked fine but I get nothing in table storage on Azure. This has worked before but I have since moved the deployment to another subscription and storage account. Because of my RDP problems, I can't even see if various files are created locally on the instance and I don't know what files to check for anyway!
Please help!
Upvotes: 1
Views: 1816
Reputation: 1852
I finally managed to get it working by following this guide: Here
Basically the only difference was in the OnStart method of my web role and rather than the code above which is found in almost all of the examples online, I had to use the following, perhaps because I am using multiple instances?
public override bool OnStart()
{
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);
DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
return base.OnStart();
}
Thank you elastacloud!
Upvotes: 3