I'm using Azure Table Storage and using CloudTable object (in Microsoft's library Microsoft.Azure.Cosmos.Table) to add a record. At the moment I have this:
Given my CloudTable object is this:
private readonly CloudTable cloudTable;
I have the following code to Upsert a record:
var upsertOp = TableOperation.InsertOrReplace(myRecord);
cloudTable.ExecuteAsync(upsertOp);
However, what I want to do is add a new record only if a record does not already exist. If one already exists then I do not want to add or update the existing.
What is the right approach to doing this? Do I use transactions in some way or can I use the TableOperation.Insert() method (I'm assuming this will throw an exception if an item already exists)?