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.
public class CosmosClientOptions
type CosmosClientOptions = class
Public Class CosmosClientOptions
- Inheritance
-
CosmosClientOptions
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
AccountInitializationCustomEndpoints |
Gets and sets the custom endpoints to use for account initialization for geo-replicated database accounts in the Azure Cosmos DB service. |
AllowBulkExecution |
Allows optimistic batching of requests to service. Setting this option might impact the latency of the operations. Hence this option is recommended for non-latency sensitive scenarios only. |
ApplicationName |
Get or set user-agent suffix to include with every Azure Cosmos DB service interaction. |
ApplicationPreferredRegions |
Gets and sets the preferred regions for geo-replicated database accounts in the Azure Cosmos DB service. |
ApplicationRegion |
Gets or sets the location where the application is running. This will influence the SDK's choice for the 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. |
CosmosClientTelemetryOptions |
Gets or sets Client Telemetry Options like feature flags and corresponding options |
CustomHandlers |
Gets the handlers run before the process |
EnableContentResponseOnWrite |
Gets or sets the boolean to only return the headers and status code in the Cosmos DB response for write item operation like Create, Upsert, Patch and Replace. Setting the option to false will cause the response to have a null resource. This reduces networking and CPU load by not sending the resource back over the network and serializing it on the client. |
EnableTcpConnectionEndpointRediscovery |
Gets or sets the flag to enable address cache refresh on TCP connection reset notification. |
GatewayModeMaxConnectionLimit |
Get or set the maximum number of concurrent connections allowed for the target service endpoint in the Azure Cosmos DB service. |
HttpClientFactory |
Gets or sets a delegate to use to obtain an HttpClient instance to be used for HTTPS communication. |
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 |
Gets or sets the maximum number of retries in the case where the request fails because the Azure Cosmos DB service has applied rate limiting on the client. |
MaxRetryWaitTimeOnRateLimitedRequests |
Gets or sets the maximum retry time in seconds for the Azure Cosmos DB service. |
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. |
PortReuseMode |
(Direct/TCP) Controls the client port reuse policy used by the transport stack. |
PriorityLevel |
Sets the priority level for requests created using cosmos client. |
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. |
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. |
ServerCertificateCustomValidationCallback |
A callback delegate to do custom certificate validation for both HTTP and TCP. |
TokenCredentialBackgroundRefreshInterval |
The SDK does a background refresh based on the time interval set to refresh the token credentials. This avoids latency issues because the old token is used until the new token is retrieved. |
WebProxy |
(Gateway/Https) Get or set the proxy information used for web requests. |