Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Azure Table Storage int field increment

I thinking about great improvement of Azure Table Storage. Is it possible to submit query to Table Storage with specific operation such as "increment entity field [name] by [value] where [PartitionKey=somestingPK] and [RowKey=somethingRK]"?

@smarx is this feature will be available?

like image 461
Vadim Novitskiy Avatar asked Nov 15 '12 13:11

Vadim Novitskiy


Video Answer


2 Answers

You can accomplish this with either Table or Page storage with ETAG tracking enabled. I use this technique to create an Identity value for each entry in Azure Table. The idea goes like this:

  • Read the value from the Page Blob, leave ETAG tracking enabled

  • Increment the retrieved value

  • POST the retrieved value, and if there is an ETAG conflict, retry the whole operation again fresh. Perhaps use an exponential backoff algorithm here to prevent overloading the target container or partition.

like image 66
makerofthings7 Avatar answered Nov 15 '22 09:11

makerofthings7


Yes, this is possible - but perhaps not exactly the way you are thinking. You are looking for the MERGE operation. To use it, you must know the entity (i.e the partition key and rowkey of the entity) you are targeting. You do not have to retrieve the entity to update it, but you must specifically address each entity either per REST call or using the batch capabilities (which has some restrictions).

like image 30
dunnry Avatar answered Nov 15 '22 07:11

dunnry