Monday, 16 November 2009

Development Storage Sync (Azure November 2009 SDK)

With the November 2009 release of the Windows Azure SDK, Microsoft have changed the development storage to support dynamic schemas - just like the real Azure environment.

Because of this change, there is no longer a need to run the Create Test Storage Tables function (hoorah!) - which also means my existing Development Storage Sync tool is now defunct too.

However not all is sunshine and fairies. In order for development storage to update its schema, you must first insert an entity with the most recent properties (see this forum). If you don't, you'll get a crash if you attempt to query on a property that's not in the schema.

Essentially this means that you still need to update your development db each time you change an entity!

To make life easier, I've updated my existing Development Storage Sync tool to do this. Using reflection, it will update the schema for your entire context in one action:

Download Development Storage Sync


The application requires a reference to your assemblies that contain your TableServiceContext - which means you can't just double-click the app to run it. However a really easy way to run the app is to create an External Tool in Visual Studio. To do this:

  1. Click Tools > External Tools...
  2. Add a new External Tool:

    The Command field should point to DevStorageSync.exe in your installation directory.

    The Arguments field should point to your assembly that contains your TableServiceContext (surround with talking marks, separate multiple assemblies with a semicolon).

Now, whenever you want to synchronise your development db, just click Tools > Sync Development Storage.

Please let me know of any bugs or feedback.



Alejandro said...

Hi Anthony,

I have the problem that you explained in the article. When I try to make a query by any field other than PartitionKey and RowKey, the query fails.

I installed your tool but when the window shows the combo box is empty so i think it is not recognizing the tables.

Also tried to insert an entity, save changes, delete the entity and save the changes, but the "SchemaXml" in table "TableContainer" does not change ().

Any help? I need to solve this issue quickly.

Thank you.

Anthony said...

Have a look at the UpdateTableProperties method in Synchroniser.cs in my source code (you can browse via the Source Code tab in CodePlex).

You'll see that I needed to do more than just insert & delete an entity to get the schema to update. This might fix your problem.

Of course it would be much easier if my tool just worked for you - are you sure that the dll you are passing into the tool is the one that contains your DataServiceContext?


Alejandro said...

Thanks for your quick response.

I looked your code and I saw your comment "For some reason, for the development storage to update the schema, we first need to run a query on the current entity. WHY?!?!?!?!?!" Good question!

I done that but first I needed to delete the Development Storage Database to clean it (maybe it was enough truncating the table TableContainer), to do that I use the following command: "c:\Program Files\Windows Azure SDK\v1.0\bin\devstore\DSInit.exe" /forceCreate

About the Tool, I think it is properly configured because when not pointing to a dll a error apears (the dll that contains the class that inherits from TableServiceContext), if you like I send you my sample app.

Thanks again.

Anthony said...

If you could send me your sample app that would be great. My email address is atsuper at hotmail dot com.


Anonymous said...


Can it be used with Microsoft Sync Service?