How to ignore table storage resources no exceptions are found without using table contexts?

In my C # application, I initialize the instance CloudTablewith the following code:

        var account = CloudStorageAccount.Parse(connectionString);
        var client = account.CreateCloudTableClient();
        client.DefaultRequestOptions.RetryPolicy = new LinearRetry();

        var table = client.GetTableReference(tableName);
        table.CreateIfNotExists();

        return table;

When I perform an operation to retrieve a record from a table store, I usually do something like:

var realEntity = _table.Value.ExecuteQuery(StreamKeyConfigurationEntity.CreateQuery(calculatedPartitionKey, calculatedRowKey))
                       .SingleOrDefault();

After it was some time in production, I noticed that 404 exceptions were returned from this line. Looking around, it seems that this is normal behavior when there are no corresponding objects in the table storage, which is annoying.

Good news. I came across several articles (for example, this one , which claim that you can get around this by setting the property IgnoreResourceNotFoundException true.

, , TableContext a CloudTable. , intellisense , , GetTableServiceContext() .

- , try/catch CloudTable stuff?

+4
1

, , REST . , , ( , try-catch).

0

Source: https://habr.com/ru/post/1630078/


All Articles