Using LINQPad with Azure Table Storage

First, we need to load up LINQPad (I’m using V5) and creation a new connection. We will use the Azure Storage Driver for this.

2016-04-13_12-12-36

Then we will enter the required credentials in order to create the connection with our storage account.

2016-04-13_12-14-18

Once we’ve completed this process we can easily run C# expressions again our table using LINQ syntax. Let’s look at a few examples.

Viewing all entries:

2016-04-13_12-08-35

Viewing a specific entry by a simple where criteria:

2016-04-13_12-16-37

Now if we wanted to do something more complex, say delete all of the entries in a table or just a specific set of entries then we need to expand our process a bit. We can use the language type of “C# program” to build an actual C# program in LINQPad.

First, for this to work we need to add some DLL and Namespace references using the query properties.

Once we’ve added these references we can write a simple void Main() program and pretend like we are working with the table in C#.

In this example we are creating a storage account variable by using the CloudStorageAccount.Parse command to parse the connection string that Azure gives us.

Then we create a table client, pull in our table, and query it for all the entries with a specific partition key.

Finally, we run all the discovered queries through a loop and delete them.

Deleting an entry using a C# program layout:2016-04-13_12-09-02

Keep in mind this is a very simple example and does not take into account batches, continuation tokens, or any sort of API limits (of which there are a few you should be aware of).

Hope this helps get you started!

Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s