Visiting the WCF Data Services Toolkit April 2011 Update

Looking for a way to expose data from Windows Azure Table Storage via an OData webservice I quickly discovered that in its current form, WCF Data Services are primarily meant to expose relational data when using the Entity Framework. Since working with Azure Storage – such as TableStorage – typically does not involve a relational data model, OData seemed to be a difficult path. Not using Entity Framework means you will have to implement your own LINQ provider to get the job done. This is not a trivial task as it involves juggling – or rather messing – around with expression trees.

At this point I discovered the WCF Data Services Toolkit on Codeplex which circumvents the need to write your own LINQ provider by using a repository pattern architecture for you to hook into. I also found documentation to get me started, however I discovered later that the documentation does not match the current (beta) release of the toolkit.

As a prerequisite, please read the author’s blog post about updating resources with the toolkit. Here he describes the IWriteableRepository interface. Please note that this documentation is partly out of date as with the april update:


IWriteableRepository interface is gone

But fear not. It is a breaking change, but simply removing it from the class declaration will do the trick. This is because methods on your repository will be called by convention (hence by reflection). This has multiple advantages which the author mentions at the end of the updating resources post.

CreateDefaultEntity has been renamed to CreateResource

While the previous change might have been obvious, this one is not. But again, this is easy to solve, just rename the method.


This is it for the changes. Some random things I discovered while using the Toolkit:

Make sure to implement CreateResource. In there, simply new up a new instance of your entity (or do more advanced stuff if necessary). Otherwise, the toolkit will try to use Activator.CreateInstance() to create an entity instance, which did not work for me because the type to create an instance from was in a different assembly. This is a known issue (#12 on Codeplex) and I sent a patch for this to the author.


Just for reference: The list of methods one can implement in the repository:

  1. public void Save(<YourType> entity)
  2. public void Remove(<YourType> entity)
  3. public void CreateRelation(<YourType> entity, <YourOtherType> relatedEntity)
  4. public object CreateResource()

So far, I really like the toolkit and how it helped me to work with Azure Storage. Keep up the good work!


Azure Storage Manager

Recently I’ve been playing around with Windows Azure and wanted to get the log files for my hosted app.

I tried to get the logs using PowerShell and that worked in one case, on another box I got errors with PowerShell and couldn’t quite tell why. Anyway, I found it tedious to set up. What I wanted was a point + click solution to have all my logs on the hard drive. Another time I realized I created a lot of tables with Azure Table Storage and wanted to clean them up. I was missing a simple tool that would help me with these tasks. So I sat down and fired up Visual Studio.

I gave this app the humble name “Azure Storage Manager” as it can deal with tables as well, at a later point in time possibly even with queues.
Currently it can do this to tables:

  • List
  • Delete

ahem, that’s about it. Now for blobs:

  • List + show properties (well, some)
  • Delete
  • Copy to hard drive
  • All of the above also applies to whole blob containers. This is important because it allows you to get a container full of blobs with one click. Multi selection of blobs and containers is also supported.

It can store and use different account settings, which might come in handy if you happen to have different storage projects on Windows Azure.

This app is completely standalone in that it does NOT require PowerShell or Azure Development SDK installed. It worked for me under XP, Vista and Windows 7, which is hardly surprising as this is what the .NET runtime is for. Just wanted to make the point πŸ™‚

To install / download the application, please head over to its ClickOnce installer site.

The following walkthrough shows how the application works.

When you start the application for the first time, it will complain that there are no settings stored. You will be presented with this screen where you can enter the information that has been given to you when you created your Azure Storage Project. You need to fill in your account name and shared key. The actual endpoints are being inferred from that information. After you press Save, your account settings will be persisted as XML files. To do so, you should specify where to put the files using Set Folder.

Set Settings Folder

In case you already have a folder with settings files in it, simply set the folder and it will show all the settings in the list on the left. Double-clicking on an item in the list will apply these settings to the application, just like pressing Use Setting does.

Settings loaded

After that initial setup,Β  you can switch to the Blob tab and you will find a listing of your blob containers and blobs. You will have to set a path in order to be able to copy blobs or containers. In this screenshot a container is selected, so any delete or copy operation will apply to the whole container includin all contained blobs. Copying on container level adds the container name to the path you specified; in this example it would create a folder C:\AzureBlobs\production to put all the listed blobs in.

Container scope

Here, we selected multiple blobs. As you can see, copy and delete now works on blob level. In this case, container name is excluded from save path.

Blob Scope

I might post the code for this app in a more technical follow-up, however I have to warn you that according to Phil Haack’s Sample Code Taxonomy, this is still prototype code. It works for me and does its job if you treat it well, but the amount of error handling that is not included in this code is tremendous πŸ˜‰

What do you think about it?