I have been using azure table storage for many years, and I'm not sure what the βrightβ way to do it is with the new WindowsAzure.Storage library, version 5.0.1-preview (for use in the new ASP.NET 5):
Problem:
Given the partition key and row key, delete the row without first checking for its existence, and without failing if it does not exist.
Current solution: This code works ... but exception handling is confusing:
public async Task DeleteRowAsync(CloudTable table, string partition, string row)
{
var entity = new DynamicTableEntity(partition, row);
entity.ETag = "*";
var op = TableOperation.Delete(entity);
try
{
await table.ExecuteAsync(op);
}
catch (Exception ex)
{
var result = RequestResult.TranslateFromExceptionMessage(ex.Message);
if (result == null || result.HttpStatusCode != 404)
throw ex;
}
}
Questions:
TranslateFromExceptionMessage... WrappedStorageException ( , ). - / 404 ? - , , ?
StorageException. , , StorageException.RequestInformation.HttpStatusCode, . "" XML ?
, ?