'ExecutAsync of TableOperation exceptions aren't consistent
I was testing around the Azure table store in C# and I came across some odd behavior. If I do this:
try {
// First, create the client
var account = CloudStorageAccount.Parse(connectionString);
var client = account.CreateCloudTableClient(new TableClientConfiguration());
// Next, create the table operation to insert or replace the item
var operation = TableOperation.Insert(new TableEntity(), true);
// Now, execute the operation
CloudTable table = Client.GetTableReference(TableName);
await table.CreateIfNotExistsAsync().ConfigureAwait(false);
await table.ExecuteAsync(operation, token).ConfigureAwait(false);
} catch (StorageException e) {
// This executes
} catch (ArgumentNullException e) {
// This does not execute
}
then I'll get a StorageException stating that The values are not specified for all properties in the entity.
However, if I do this:
try {
// First, create the client
var account = CloudStorageAccount.Parse(connectionString);
var client = account.CreateCloudTableClient(new TableClientConfiguration());
// Next, create the table operation to insert or replace the item
var operation = TableOperation.Merge(new TableEntity {ETag: "*"}, true);
// Now, execute the operation
CloudTable table = Client.GetTableReference(TableName);
await table.CreateIfNotExistsAsync().ConfigureAwait(false);
await table.ExecuteAsync(operation, token).ConfigureAwait(false);
} catch (StorageException e) {
// This does not execute
} catch (ArgumentNullException e) {
// This executes
}
then I get an ArgumentNullException stating that Value cannot be null. (Parameter 'Merge requires a valid PartitionKey').
I would expect similar data conditions to produce similar errors on add and update so why do I get a StorageException when the partition key is empty on insert but an ArgumentNullException when the partition key is empty on merge?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
