Welcome to EMC Consulting Blogs Sign in | Join | Help

SSIS Junkie

LINQPad and Azure

Since I started dealing with Azure tables I’ve become frustrated that there is no ad-hoc query tool, nothing equivalent to SQL Server Management Studio. Then I heard about LINQPad and figured there must be a way to use it to query Azure tables using LINQ and indeed there is as I’ll explain here (this post assumes that you have a working knowledge of LINQPad and Azure storage).

Firstly you need to reference the correct assemblies. I’ve been using the StorageClient that is provided with the Azure Samples in the Azure SDK (March 2009 CTP of the SDK linked here) which in turn uses ADO.Net Services client library hence you’ll need to reference the following assemblies:

  • StorageClient.dll
  • System.Data.Services.Client.dll

You’ll also need to reference your DataServiceContext implementation. For demo purposes I am pulling data from my Tweetpoll application so I’m referencing the assembly containing my TweetPollDataServiceContext class - TweetPoll.dll:

image

We also need to import the namespaces into LINQPad. You’ll need the following:

  • Microsoft.Samples.ServiceHosting.StorageClient
  • System.Data.Services.Client

plus whichever namespace holds your DataServiceContext implementation:

image

Thereafter you just need to write some code. You need to supply the following:

  1. Your Azure storage account name
  2. Your Azure storage shared key
  3. The name of your DataServiceContext implementation
  4. A LINQ query

Here’s my code:

var accountName = "jamiekt";  // 1) Enter your storage account name
var sharedKey = "smXblLn+UgXR6ysbIhoeTfE3dyOZhAaONXOP/SUawRSLzCWwDXrhkpRG45A5aeAP5IEjSBEN2mEmPM8O5HnWGQ=="; // 2) SharedKey
var uri = new System.Uri("http://table.core.windows.net/");
var tableAccountInfo = new StorageAccountInfo(uri, null, accountName, sharedKey);
 
var svc = new TweetPollDataServiceContext(tableAccountInfo); // 3) Specify your DataServiceContext
 
// 4) Supply your query
var query = from row in svc.Table 
                       select row;
query.Dump();

And here are the results in LINQPad:
image
Hope that helps!!!

@Jamiet

Published Monday, July 06, 2009 4:51 PM by jamie.thomson

Comments

 

The Technology Post for July 6th, 2009 | rapid-DEV.net said:

July 7, 2009 12:45 PM
 

SSIS Junkie said:

I read an article today called The Longest Tweet In History which explained how it is now possible to

July 10, 2009 11:59 AM
New Comments to this post are disabled

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems