My annoying ‘gotcha’ in Azure Table Storage and Node.js

I have been dabbling in a little pet project on and off which recreates an on-line fridge magnet scenario. http://fridgemagnet.azurewebsites.net/client1.html.

Don’t get excited about the code structure, this is a work in progress/proof of concept project so please, no comments.

Anyway, the issue I was facing was that I was using Azure simple table storage to persist the state between sessions but for some reason, I wasn’t  able to save to the table storage.

Everything was reporting correctly so i assumed that it was saving the data but it wasn’t.

The original code was this

var entGen = azure.TableUtilities.entityGenerator;


var task = {
PartitionKey: entGen.String(partkey),
RowKey: entGen.String('1'),
data: stringrep
};

Where stringrep was a string representation of my array of tiles.

The system always reported that the task was successful and no errors were reported.

I finally found a little comment written by another which highlighted a ‘gotcha’.

Essentially, the code above needed to be written as follow:

var task = {
PartitionKey: entGen.String(partkey),
RowKey: entGen.String('1'),
data: entGen.String(stringrep)
};

Note the change “entGen.String(stringrep)” – doing this was the silver bullet and suddenly the data actually saved.

I hope this helps anyone else out there that is having starter issues with Azure table storage.

Advertisements
Posted in Uncategorized

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: