Windows Azure Diagnostics Sample Code

I uploaded a Windows Azure Diagnostics sample to the MSDN Code Samples Gallery. The sample demonstrates how to use the parts of the Windows Azure Diagnostics API I covered in earlier posts on Windows Azure Diagnostics and its management.

The sample can be downloaded from here. Its description is:

Windows Azure Diagnostics provides a coherent method of capturing log information, from various sources, in a Windows Azure instance and then transferring it to Windows Azure Storage.  Various types of information can be captured including Windows Event Logs, Performance Counters, Trace logs, and custom logs. This information remains on the instance with a consequent risk of loss until it is transferred to Windows Azure Storage. WAD therefore provides for the scheduled and on-demand transfer of the captured information to Windows Azure Storage. Event-based logs are transferred to table storage while file-based logs are transferred to blog storage.

WAD is started automatically on all instances of a role for which the ServiceDefinition.csdef file contains an import specification for the Diagnostics module. WAD is configured at instance startup by retrieving the default initial configuration and modifying it to specify which logs to capture and the schedule with which they should be transferred. In the sample, this is performed in WebRole.cs.

The configuration for WAD is stored in instance-specific XML documents in blob storage. In the sample, the WAD configuration for each instance is retrieved from blob storage and displayed in the Configuration page. The Logs page in the sample displays the last five minutes of performance counter data transferred to table storage.

The WAD API supports remote configuration. This is useful when a change is required in the captured information such as adding one or more performance counters or changing the periodicity of the scheduled transfers. Another use is the request of an on-demand transfer when there is an immediate need to access the captured logs without waiting for the next scheduled transfer. In the sample, the Configuration page associates two buttons with the configuration of each instance. One button adds the capture of an additional performance counter while the other requests an on-demand transfer. These requests are then reflected in the instance configuration displayed on the page.

Once an on-demand transfer has been requested for an instance it is not possible to modify the WAD configuration again until the on-demand transfer has been formally ended. This cleanup removes the configuration of the on-demand transfer from the WAD configuration.  The cleanup should also remove the message from the notification queue used to indicate completion of the transfer. In the sample, the OnDemandTransfer page demonstrates this cleanup.


About Neil Mackenzie

Cloud Solutions Architect. Microsoft
This entry was posted in Diagnostics, Windows Azure and tagged , . Bookmark the permalink.

One Response to Windows Azure Diagnostics Sample Code

  1. Andy Cross says:

    Nice code sample Neil!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s