Should I check TableResult for error codes after performing ExecuteAsync on a CloudTable?
Asked Answered
C

1

6

I run a simple command against Azure Table Storage:

var operation = TableOperation.InsertOrReplace(entity);
await cloudTable.ExecuteAsync(operation);

Now the result that is returned by ExecuteAsync is not just Task, but Task<TableResult>. TableResult contains HttpStatusCode. Does that mean that operation can just execute without throwing any exception and the status code will be 500 or something and I need to verify these things myself? Or will I only get success codes and exception otherwise.

I can't find any documentation on that one and it's not easy to provoke an error from Table Storage to figure out how it works.

P.S. I use Microsoft.WindowsAzure.Storage.Table now, but plan to switch to the newly developed library for Cosmos for .Net Core, but it is still beta.

P.P.S. Have figured out that it is used e.g. for 404 when element is not found which is actually expected and not an exception. Also wrong key will result in exception that is probably the result of 403 or 401. Still not clear whether failures will result in exception or not, but all points in the direction that an exception will be thrown.

Consentient answered 19/2, 2019 at 11:39 Comment(2)
I always do. Can't hurt. I saw some transients that were caught until I found cloudClient.DefaultRequestOptions.RetryPolicy = myRetryPolicy; then the need sort of went away. In some etag type situations with optimistic concurrency was also useful to check.Belfast
It can't hurt of course, but I'd rather have the library do the work for me, if it is of course capable of doing this, that's it.Consentient
P
0

Best to use the Azure.Data.Tables package which is the most current and recommended nuget package for working with Azure Table Storage. https://www.nuget.org/packages/Azure.Data.Tables/

All Azure SDKs should throw an exception if a request failed:

DO throw RequestFailedException or its subtype when a service method fails with non-success status code.

https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-errors

That said, doesn't hurt to double-check.

Peipeiffer answered 28/2 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.