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.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)