1

I want to add tracing to my startup tasks. I was trying to enable DiagnosticsMonitorTraceListener in a powershell script that runs before all the actual startup tasks. Code:

Add-Type -Path ./Microsoft.WindowsAzure.Diagnostics.dll
$listener = new-object -type Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener 

[System.Diagnostics.Trace]::Listeners.Add($listener)

$credentials = new-object -type Microsoft.WindowsAzure.StorageCredentialsAccountAndKey -argumentlist "ACCOUNT_NAME", "ACCOUNT_KEY"
$dmConfig = Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor]::GetDefaultInitialConfiguration();
$dmConfig.Logs.ScheduledTransferPeriod = [System.TimeSpan]::FromMinutes(1)
[Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor]::Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", $dmConfig)

For some reason my traces like this:

[System.Diagnostics.Trace]::TraceInformation("Starting startup tasks")

never end up transferred to Azure Storage. The script runs without any problem. I know that there is a way to make Azure Diagnostic Infrastructure to copy logs generated by startup tasks but as far as I understand, the DiagnosticMonitor gets started only when a role starts. What if a startup task fail and the role never gets to run - the logs are not persisted.

Please let me know if I'm going the wrong way to solve this. Thanks.

1 Answer 1

0

One alternative if you are using Visual Studio Ultimate is to use IntelliTrace. That can look at a lot of things during startup. For external tasks, and things like that, check out:

http://blog.smarx.com/posts/windows-azure-startup-tasks-tips-tricks-and-gotchas

And

http://leastprivilege.com/2011/03/04/logging-output-of-azure-startup-tasks-to-the-event-log/

1
  • Startup tasks run on on remote machine to which I may not have access, e.g, production server. If I decide to write to event log I'll still need to write custom logic that will persist Event Logs in Azure storage when one of the startup tasks fails (DiagnosticMonitor will never be started).
    – Janusz
    Jan 21, 2012 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.