views:

44

answers:

1

I have tried to use the samples that Roger Jennings recommeded in his book, "Cloud Computing with Windows Azure", but he is using version 1. I'm using v1.2 and there is a lot of differences. Firstly, I had to recompile the StorageClient DLL with the corrected namespace and other changes. Then, when I use his code to create a Table at the application start, I get an "out of range index".

Has anyone managed to successfully create a Table at application startup? If so, how? Also, if there are any tutorials/samples that use version 1.2, I'd greatly appreciate them too.

+4  A: 

You no longer have to rebuild the sample storage client library. v1.2 will automagically add three DLL references to your role:

  • Microsoft.WindowsAzure.Diagnostics
  • Microsoft.WindowAzure.ServiceRuntime
  • Microsoft.WindowsAzure.StorageClient

To create a table, you'll need to first set up your table :

  • Create a class deriving from TableServiceEntity (say, "MyEntity")-
  • Derive a table class from TableServiceContext (say, "MyEntityDataServiceContext"). In that class, create a property of type DataServiceQuery < MyEntity >() that returns CreateQuery < MyEntity > ("MyEntities");

Once you've done that, create the table with code like this:

var account = CloudStorageAccount.DevelopmentStorageAccount;
CloudTableClient.CreateTablesFromModel(typeof(MyEntityDataServiceContext),account.TableEndpoint.AbsoluteUri, account.Credentials);

For a much more detailed look at this, download the Azure Platform Training Kit, June 2010. There's a lab called "Exploring Windows Azure Storage" that covers all this.

David Makogon
+1: Just for the word "automagically" :o) Will let you know how I get on. Thanks for the answer.
Ardman