How To: Query Azure Log Tables with LINQPad

by Jason Haley 28. January 2010 12:09

Code Download: AzureLogsWithLINQPad.zip

Recently there have been some questions in the Windows Azure Forum about retrieving information from the Azure log tables, which have made me think it would be nice to just run a quick query against Azure table storage. 

Normally I use the Azure Storage Explorer (or sometimes the TableBrowser site) to view data in Azure table storage … however the filtering functionality is still a little limited with those tools.  And in the past I’ve looked at LINQPad but hadn’t taken the time to figure out how to use it with Azure table storage until today.

LINQPad (http://www.linqpad.net/) is a great utility for executing LINQ queries against a data source.  With LINQPad, you can use things like LINQ to Objects, LINQ to SQL and several other LINQ oriented ways to query a data source … but to use it with Azure table storage you need to do a little work which Jamie Thomson wrote up in July 2009.  His blog entry describes how hookup Azure table storage to LINQPad: LINQPad and Azure.  Please check his entry out for a background on what the rest of this entry is about … I’m basically just updating his.

What I want to do, is use LINQPad to query the log tables generated by Windows Azure.  When Windows Azure is populating the different diagnostic logs, some are transferred to tables (others go to blobs).

Here is a list of the tables Windows Azure creates and what is in them:

WADLogsTable Trace logs
WADDiagnosticInfrastructureLogsTable Infrastructure Logs
WADWindowsEventLogsTable Windows Event Logs (configured manually)
WADPerfomanceCountersTable Performance Counters (configured manually)

image

In order to have all the DataContext classes available for querying these log tables, I put together a small solution which contains the entities and data context classes.  The link for the download is at the beginning of this entry.

Once you have the AzureLogs solution compiled, getting LINQPad setup to make queries to these tables is pretty close to what Jamie outlined in his blog entry, but I’ll update the steps here (for the Nov 2009 release).

 

Step 1: Add the additional references

  • In LINQPad, go to the Query menu | Advanced Query Properties
  • Add the AzureLogs.dll
  • Add the Microsoft.WindowsAzure.Diagnostics.dll and the Microsoft.WindowsAzure.StorageClient.dll (if you compile the source included in the download, these will be in the bin\debug directory after you compile)
  • Add the System.Data.Services.Client.dll

image

Step 2: Add the additional namespace imports

  • Add the additional namespaces shown in the image below

image

Step 3: Set the language

  • In order to run multiple statements in LINQPad (which you’ll want to do), you need to change the Language to C# Statement(s).

image

Step 4: Write the query and Run it

If you open the query included with the download (WindowsAzureLogsQuery.linq), it will save you some time – you’ll just need to do the following then uncomment and edit the queries already started for you.

By default the WindowsAzureLogsQuery.linq is using the local storage account.

To point at a different storage account:

  • Edit the accountName and the sharedKey to your storage account settings
  • Uncomment the “var account” lines that uses those
  • Comment out the line that sets the account variable to the development storage

image

Comments (1) | Post RSSRSS comment feed |

Categories: Azure
Tags:

Comments

Comments are closed