Cancellation Token support for Cosmos Document Client?

Viewed 504

We are using Microsoft.Azure.Documents.Client Version=1.12.0.0 to make calls to Azure Cosmos DB. We have seen delays where some requests take long time (like 20min) to process the request because during load our production machine starve for connection pool. Due to this the requests our service is processing times out on our end but there is no way to pass the cancellation token to async requests to cosmos db that our service is waiting for. Are there any recommendation for this?

1 Answers

Since the library itself doesn't support CancellationTokens, the suggested way would be to use something like Polly, specifically a timeout policy.

Relevant in your case

  • Use TimeoutAsync
  • Use pessimistic timeout strategy since the library does not support cancellation
Related