Closed khsiehms closed 1 week ago
Hi @khsiehms, I believe that you will be able to achieve what you want using user defined handlers.. You should be able to define a custom handler that will be able to retry in the circumstances you mentioned above. I have linked the SDK design document above, which describes the handler pipeline structure. I will also link a sample library we have for custom handlers here so you can get started with some examples. Please feel free to re-open this issue if you have any other questions.
Does the CosmosClient support custom retry policies and logic?
We are trying to utilize the CosmosClient like:
CosmosClient cosmosClient = new CosmosClient("account-endpoint-from-portal", "account-key-from-portal", new CosmosClientOptions());
Container container = db.GetContainer("database-id", "container-id");
container.GetItemQueryIterator();
However, based on the documentation (CosmosClientOptions Class), it appears we can only specify the maximum retry attempts for throttling in CosmosClientOptions.
Is there a way to set up custom retry policies and logic for different errors?
For example, we might also want to retry on receiving a 503 (Service Unavailable) response or attempt to create the container if a 404 (Not Found) response is received on the first request.
If there is no way to specify the custom retry logic through the options, what would be your suggestion for achieving it?