WindowsAzure/azure-sdk-for-node — Issue #13: TableService.insertOrReplaceEntity doesn't work
Author: bergie
Created: 2011-12-16 15:42:38+00:00
State: open

I'm using TableStorage for storing server access logs in [my Azure CoffeeScript tutorial](http://universalruntime.tumblr.com/post/14303346830/running-coffeescript-on-microsoft-azure). I also have a worker process that calculates access counts per URL.

To make this idempotent, I'm using a modified URL as the `RowKey`, and tried to use `insertOrReplaceEntity`. That always failed so I had to rewrite my code as:

countRequests url, (total) ->
key = "url-#{url.replace('/', '-')}"
totalEntry =
total: total
RowKey: key
PartitionKey: 'totals1'
table.insertEntity 'requestTotal', totalEntry, (error) ->
return unless error
table.updateEntity 'requestTotal', totalEntry, (error) ->
console.log "Failed to update request count for #{url} to #{total}", error if error