ConnectionPolicy.RetryOptions Property

Definition

Gets or sets the RetryOptions associated with the DocumentClient in the Azure Cosmos DB service.

public Microsoft.Azure.Documents.Client.RetryOptions RetryOptions { get; set; }
member this.RetryOptions : Microsoft.Azure.Documents.Client.RetryOptions with get, set
Public Property RetryOptions As RetryOptions

Property Value

If this property is not set, the SDK uses the default retry policy that has MaxRetryAttemptsOnThrottledRequests set to 9 and MaxRetryWaitTimeInSeconds set to 30 seconds.

Examples

The example below creates a new DocumentClient and sets the ConnectionPolicy using the RetryOptions property.

MaxRetryAttemptsOnThrottledRequests is set to 3, so in this case, if a request operation is rate limited by exceeding the reserved throughput for the collection, the request operation retries 3 times before throwing the exception to the application. MaxRetryWaitTimeInSeconds is set to 60, so in this case if the cumulative retry wait time in seconds since the first request exceeds 60 seconds, the exception is thrown.


 ConnectionPolicy connectionPolicy = new ConnectionPolicy();
 connectionPolicy.RetryOptions.MaxRetryAttemptsOnThrottledRequests = 3;
 connectionPolicy.RetryOptions.MaxRetryWaitTimeInSeconds = 60;

DocumentClient client = new DocumentClient(new Uri("service endpoint"), "auth key", connectionPolicy);

Remarks

For more information, see Handle rate limiting/request rate too large.

Applies to

See also