Skip to content

Instantly share code, notes, and snippets.

@gbellmann
Created April 17, 2015 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbellmann/6882a86535e8c302e4cc to your computer and use it in GitHub Desktop.
Save gbellmann/6882a86535e8c302e4cc to your computer and use it in GitHub Desktop.
Function that updates a record in Azure Table Storage
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
public void ShipOrder(CloudStorageAccount storageAccount, string partitionKey, string rowKey)
{
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("orders");
TableOperation retrieveOperation = TableOperation.Retrieve<OrderEntity>(partitionKey, rowKey);
TableResult retrievedResult = table.Execute(retrieveOperation);
OrderEntity toUpdate = (OrderEntity) retrievedResult.Result;
if (toUpdate != null)
{
toUpdate.Status = "shipped";
toUpdate.ShippedDate = Convert.ToDateTime("20150417");
TableOperation insertOrReplaceOperation = TableOperation.InsertOrReplace(toUpdate);
table.Execute(insertOrReplaceOperation);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment