Table Storage Hiccups

So, like most of us, I thought hooking up table storage would be easy.  Turns out, it’s not if like to keep up with the latest and greatest support libraries.

The first hiccup came when I tried to connect to my local storage service (UseDevelopmentStorage=true).  Well, now you need to specify the URI that points to the local storage emulator and like the blog post author states, “it just magically works”

Now that I had the table sitting there, the next hiccup came when I asked my table service context to build the table if it doesn’t exist.  This one was kind of bad, not something I expected.  First I used the Azure SDK library my exception told me I needed, in this case Microsoft.Data.OData (v5.2.0.0).    There’s a newer version of it as well, v.5.4.0.0, that didn’t work either even with an assembly binding redirect.  I installed v5.4 with NuGet and then had to uninstall it manually by clearing out the package.config entries and dropping the references.  Then using the Package Manager Console I installed v.5.0.2.0 instead w/o the binding redirect and it worked.

The last hiccup was getting the entities to insert into the table.  You can find more about CRUD here, and Table Storage CRUD operations here.  A side note on that embedded link, it discusses versions 1.7 and 2.0 – yesterday I was looking at 1.7, not 2.0 so check which form of the page you are looking at before you start coding.

My partition key was missing and the row key and the timestamp properties were null.  I read that the table client took care of this for me, so I used DateTime.UtcNow for a default property, and fixed up my extension method that gen’d my TableEntity for me.  That error came in the form of [ The remote server returned an error: (400) Bad Request ].

Here are the links I eventually found that bailed me out today.  All the code is working and I added a few more guard statements to do some additional state checks before the CRUD bits fire.  Hopefully, the blob storage stuff is ironed out implicitely as well with all of this dependency churn today.

HTH / oFc

Differences between Azure Storage Client Library 1.7 and 2.0

If you decide to use v5.0.2.0 read this.

What Azure allows inside a table entity during CRUD operations

How to use the Table Storage Service

Technical Evaporation…

This is the process of getting some data out of the local environment and up to the cloud – actually this is what evaporation is – the moisture has to come from somewhere whether its my backyard or the Gulf of Mexico and get up into the atmosphere and form the cloud to make the rain, right?

Like I mentioned, in the previous post I have been using mock data to get some of the view plumbing working so now I need to actually being taking things off my Azure Service Bus queue and putting them somewhere else.  I didn’t think about this b/c I just wanted to let the app’s development process lead me to the next feasible (and cheapest) choice for storage and persistence.  And the thought in the back of my mind is something that Ayenda Rahein said in a keynote a few years ago… “we should be optimizing for persisting data, not retrieving it.”  Yeah, pretty big statement, but it’s true.

So, the simplest thing I could do would be to persist everything into Azure table or blob storage until there’s some requirement for reporting then maybe a database can come into play.  I have to pay extra storage and compute costs on my Azure account to host a database and I don’t really need a full blown database instance right now.  I can just figure out what I need by stuffing things into something flatter and cheaper.  But, if I code this right, I should be able to move it into an instance if something triggers that need.

Moving on.

I settled on blob storage for my logging and table storage for my application data.  I built my code from this post which had some quick and dirty examples about accessing Azure’s table storage.  It turned out nice so hopefully it can be extended for other table storage persistence needs in the future.  Not as generic as I would have liked it, but it works for now.

Now, the app is throwing something somewhere b/c the local worker role is puking and coughing pretty hard right now.  So, back to my earlier post from yesterday, even though my tests are passing I need something to catch this junk so I look at it.  This will allow me to wire up the blob storage client – oh, there’s the PowerShell stuff to get to as well.  Should be a full(er) day today.

HTH / 0Fc