Redirecting standard-out trace messages from custom processes to Windows Azure diagnostics manager
Trying to troubleshoot Windows Azure Compute role startup issues

Querying Windows Azure Table Storage with LINQPad

Last week I wanted to quickly query and test data from one of my Windows Azure Table Storage tables. I did not want to use a storage tool as I wanted to have more fine-grained query control – and I sure did not want to write a custom program in Visual Studio.

What I ended up with is using the wonderful LINQPad to query Azure Table Storage. How does this work?

  1. Add the necessary DLLs to LINQPad by opening Query Properties from the Query menu. Then add references to these assemblies:
    -System.Data.Services.Client.dll
    -Microsoft.WindowsAzure.StorageClient.dll
    -<all assemblies you need for querying table storage via your custom DataServiceContext />

    image
  2. Next we need to import the .NET namespaces we need in our code. In my case it looks like this:

    image


That’s it.
Now we can use a C# program snippet like the following to successfully query our table(s):

void Main()
{
    var accountName = "…";    
    var sharedKey = "…";    
    var storageCredentials = new StorageCredentialsAccountAndKey(accountName, sharedKey);
    var storageAccount = new CloudStorageAccount(storageCredentials, true);
           
    var storageService = new MeldungenDataServiceContext(
        storageAccount.TableEndpoint.ToString(), 
        storageCredentials);
    
    var competitions =
        from competition in storageService.Wettkaempfe    
        select competition;            
    competitions.Dump();    
}

Just to prove it Winking smile:

image

Nice.

Note: make sure to spend a few bucks on LINQPad to get full IntelliSense – this just rocks Smile

Hope this helps.

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

The comments to this entry are closed.