CosmosClientOptions Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines all the configurable options that the CosmosClient requires.
[System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonCosmosClientOptionsConverter))]
public class CosmosClientOptions : Azure.Core.ClientOptions
[<System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonCosmosClientOptionsConverter))>]
type CosmosClientOptions = class
inherit ClientOptions
Public Class CosmosClientOptions
Inherits ClientOptions
- Inheritance
- Attributes
Examples
An example on how to configure the serialization option to ignore null values CosmosClientOptions clientOptions = new CosmosClientOptions() { SerializerOptions = new CosmosSerializationOptions(){ IgnoreNullValues = true }, ConnectionMode = ConnectionMode.Gateway, };
CosmosClient client = new CosmosClient("endpoint", "key", clientOptions);
Constructors
CosmosClientOptions() |
Creates a new CosmosClientOptions |
Properties
ApplicationName |
Get or set user-agent suffix to include with every Azure Cosmos DB service interaction. |
ApplicationRegion |
Get or set the preferred geo-replicated region to be used for Azure Cosmos DB service interaction. |
ConnectionMode |
Get or set the connection mode used by the client when connecting to the Azure Cosmos DB service. |
ConsistencyLevel |
This can be used to weaken the database account consistency level for read operations. If this is not set the database account consistency level will be used for all requests. |
Diagnostics |
Gets the client diagnostic options. (Inherited from ClientOptions) |
GatewayModeMaxConnectionLimit |
Get or set the maximum number of concurrent connections allowed for the target service endpoint in the Azure Cosmos DB service. |
IdleTcpConnectionTimeout |
(Direct/TCP) Controls the amount of idle time after which unused connections are closed. |
LimitToEndpoint |
Limits the operations to the provided endpoint on the CosmosClient. |
MaxRequestsPerTcpConnection |
(Direct/TCP) Controls the number of requests allowed simultaneously over a single TCP connection. When more requests are in flight simultaneously, the direct/TCP client will open additional connections. |
MaxRetryAttemptsOnRateLimitedRequests |
Get or set the number of times client should retry on rate throttled requests. |
MaxRetryWaitTimeOnRateLimitedRequests |
Get or set the max time to client is allowed to retry on rate throttled requests. |
MaxTcpConnectionsPerEndpoint |
(Direct/TCP) Controls the maximum number of TCP connections that may be opened to each Cosmos DB back-end. Together with MaxRequestsPerTcpConnection, this setting limits the number of requests that are simultaneously sent to a single Cosmos DB back-end(MaxRequestsPerTcpConnection x MaxTcpConnectionPerEndpoint). |
OpenTcpConnectionTimeout |
(Direct/TCP) Controls the amount of time allowed for trying to establish a connection. |
RequestTimeout |
Gets the request timeout in seconds when connecting to the Azure Cosmos DB service. The number specifies the time to wait for response to come back from network peer. |
Retry |
Gets the client retry options. (Inherited from ClientOptions) |
RetryPolicy |
Gets or sets the policy to use for retries. If a policy is specified, it will be used in place of the Retry property. The RetryPolicy type can be derived from to modify the default behavior without needing to fully implement the retry logic. If Process(HttpMessage, ReadOnlyMemory<HttpPipelinePolicy>) is overridden or a custom HttpPipelinePolicy is specified, it is the implementer's responsibility to update the ProcessingContext values. (Inherited from ClientOptions) |
Serializer |
Get to set an optional JSON serializer. The client will use it to serialize or de-serialize user's cosmos request/responses. SDK owned types such as DatabaseProperties and ContainerProperties will always use the SDK default serializer. |
SerializerOptions |
Get to set optional serializer options. |
Transport |
The HttpPipelineTransport to be used for this client. Defaults to an instance of HttpClientTransport. (Inherited from ClientOptions) |
WebProxy |
(Gateway/Https) Get or set the proxy information used for web requests. |
Methods
AddPolicy(HttpPipelinePolicy, HttpPipelinePosition) |
Adds an HttpPipeline policy into the client pipeline. The position of policy in the pipeline is controlled by the |