### YamlMime:JavaType uid: "com.azure.cosmos.CosmosClientBuilder" fullName: "com.azure.cosmos.CosmosClientBuilder" name: "CosmosClientBuilder" nameWithType: "CosmosClientBuilder" summary: "Helper class to build and instances as logical representation of the Azure Cosmos database service." inheritances: - "" inheritedClassMethods: - classRef: "java.lang.Object" methodsRef: - "clone" - "equals" - "finalize" - "getClass" - "hashCode" - "notify" - "notifyAll" - "toString" - "wait" - "wait" - "wait" syntax: "public class **CosmosClientBuilder**
implements <>, <>, <>" constructors: - uid: "com.azure.cosmos.CosmosClientBuilder.CosmosClientBuilder()" fullName: "com.azure.cosmos.CosmosClientBuilder.CosmosClientBuilder()" name: "CosmosClientBuilder()" nameWithType: "CosmosClientBuilder.CosmosClientBuilder()" summary: "Instantiates a new Cosmos client builder." syntax: "public CosmosClientBuilder()" desc: "Instantiates a new Cosmos client builder." methods: - uid: "com.azure.cosmos.CosmosClientBuilder.addOperationPolicy(com.azure.cosmos.CosmosOperationPolicy)" fullName: "com.azure.cosmos.CosmosClientBuilder.addOperationPolicy(CosmosOperationPolicy policy)" name: "addOperationPolicy(CosmosOperationPolicy policy)" nameWithType: "CosmosClientBuilder.addOperationPolicy(CosmosOperationPolicy policy)" summary: "Adds a policy for modifying request options dynamically." parameters: - description: "the policy to add" name: "policy" type: "" syntax: "public CosmosClientBuilder addOperationPolicy(CosmosOperationPolicy policy)" desc: "Adds a policy for modifying request options dynamically. The last policy defined aimed towards the same operation type will be the one ultimately applied." returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.authorizationTokenResolver(com.azure.cosmos.models.CosmosAuthorizationTokenResolver)" fullName: "com.azure.cosmos.CosmosClientBuilder.authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)" name: "authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)" nameWithType: "CosmosClientBuilder.authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)" summary: "Sets the token resolver" parameters: - description: "the token resolver" name: "cosmosAuthorizationTokenResolver" type: "" syntax: "public CosmosClientBuilder authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)" desc: "Sets the token resolver" returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.buildAsyncClient()" fullName: "com.azure.cosmos.CosmosClientBuilder.buildAsyncClient()" name: "buildAsyncClient()" nameWithType: "CosmosClientBuilder.buildAsyncClient()" summary: "Builds a cosmos async client with the provided properties" syntax: "public CosmosAsyncClient buildAsyncClient()" desc: "Builds a cosmos async client with the provided properties" returns: description: "CosmosAsyncClient" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.buildClient()" fullName: "com.azure.cosmos.CosmosClientBuilder.buildClient()" name: "buildClient()" nameWithType: "CosmosClientBuilder.buildClient()" summary: "Builds a cosmos sync client with the provided properties" syntax: "public CosmosClient buildClient()" desc: "Builds a cosmos sync client with the provided properties" returns: description: "CosmosClient" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryConfig(com.azure.cosmos.models.CosmosClientTelemetryConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)" name: "clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)" nameWithType: "CosmosClientBuilder.clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)" summary: "Returns the client telemetry config instance for this builder" parameters: - description: "the client telemetry configuration to be used" name: "telemetryConfig" type: "" syntax: "public CosmosClientBuilder clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)" desc: "Returns the client telemetry config instance for this builder" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryEnabled(boolean clientTelemetryEnabled)" name: "clientTelemetryEnabled(boolean clientTelemetryEnabled)" nameWithType: "CosmosClientBuilder.clientTelemetryEnabled(boolean clientTelemetryEnabled)" summary: "Sets the flag to enable client telemetry which will periodically collect database operations aggregation statistics, system information like cpu/memory and send it to cosmos monitoring service, which will be helpful during debugging." parameters: - description: "flag to enable client telemetry." name: "clientTelemetryEnabled" type: "" syntax: "public CosmosClientBuilder clientTelemetryEnabled(boolean clientTelemetryEnabled)" desc: "Sets the flag to enable client telemetry which will periodically collect database operations aggregation statistics, system information like cpu/memory and send it to cosmos monitoring service, which will be helpful during debugging.\n\nDEFAULT value is false indicating this is opt in feature, by default no telemetry collection." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)" name: "connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)" nameWithType: "CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)" summary: "Enables connections sharing across multiple Cosmos Clients." parameters: - description: "connection sharing" name: "connectionSharingAcrossClientsEnabled" type: "" syntax: "public CosmosClientBuilder connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)" desc: "Enables connections sharing across multiple Cosmos Clients. The default is false.\n\n\n\n```java\nCosmosAsyncClient client1 = new CosmosClientBuilder()\n .endpoint(serviceEndpoint1)\n .key(key1)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .buildAsyncClient();\n\n CosmosAsyncClient client2 = new CosmosClientBuilder()\n .endpoint(serviceEndpoint2)\n .key(key2)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .buildAsyncClient();\n\n // when configured this way client1 and client2 will share connections when possible.\n```\n\n\nWhen you have multiple instances of Cosmos Client in the same JVM interacting to multiple Cosmos accounts, enabling this allows connection sharing in Direct mode if possible between instances of Cosmos Client.\nPlease note, when setting this option, the connection configuration (e.g., socket timeout config, idle timeout config) of the first instantiated client will be used for all other client instances.\n" returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.consistencyLevel(com.azure.cosmos.ConsistencyLevel)" fullName: "com.azure.cosmos.CosmosClientBuilder.consistencyLevel(ConsistencyLevel desiredConsistencyLevel)" name: "consistencyLevel(ConsistencyLevel desiredConsistencyLevel)" nameWithType: "CosmosClientBuilder.consistencyLevel(ConsistencyLevel desiredConsistencyLevel)" summary: "Sets the to be used\nBy default, consistency will be used." parameters: - description: "" name: "desiredConsistencyLevel" type: "" syntax: "public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyLevel)" desc: "Sets the to be used\nBy default, consistency will be used." returns: description: "current Builder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.contentResponseOnWriteEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)" name: "contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)" nameWithType: "CosmosClientBuilder.contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)" summary: "Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on CosmosItem." parameters: - description: "a boolean indicating whether payload will be included in the response or not" name: "contentResponseOnWriteEnabled" type: "" syntax: "public CosmosClientBuilder contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)" desc: "Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on CosmosItem.\nIf set to false (which is by default), service doesn't return payload in the response. It reduces networking and CPU load by not sending the payload back over the network and serializing it on the client.\nThis feature does not impact RU usage for read or write operations.\nBy-default, this is false." returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.credential(com.azure.core.credential.AzureKeyCredential)" fullName: "com.azure.cosmos.CosmosClientBuilder.credential(AzureKeyCredential credential)" name: "credential(AzureKeyCredential credential)" nameWithType: "CosmosClientBuilder.credential(AzureKeyCredential credential)" summary: "Sets the to be used" parameters: - description: "" name: "credential" type: "" syntax: "public CosmosClientBuilder credential(AzureKeyCredential credential)" desc: "Sets the to be used" returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.credential(com.azure.core.credential.TokenCredential)" fullName: "com.azure.cosmos.CosmosClientBuilder.credential(TokenCredential credential)" name: "credential(TokenCredential credential)" nameWithType: "CosmosClientBuilder.credential(TokenCredential credential)" summary: "Sets the used to authorize requests sent to the service." parameters: - description: " used to authorize requests sent to the service." name: "credential" type: "" syntax: "public CosmosClientBuilder credential(TokenCredential credential)" desc: "Sets the used to authorize requests sent to the service. Refer to the Azure SDK for Java [identity and authentication][] documentation for more details on proper usage of the type.\n\n\n[identity and authentication]: https://aka.ms/azsdk/java/docs/identity" returns: description: "the updated CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.customItemSerializer(com.azure.cosmos.CosmosItemSerializer)" fullName: "com.azure.cosmos.CosmosClientBuilder.customItemSerializer(CosmosItemSerializer customItemSerializer)" name: "customItemSerializer(CosmosItemSerializer customItemSerializer)" nameWithType: "CosmosClientBuilder.customItemSerializer(CosmosItemSerializer customItemSerializer)" summary: "Sets a custom serializer that should be used for conversion between POJOs and Json payload stored in the Cosmos DB service." parameters: - description: "the custom serializer to be used for item payload transformations" name: "customItemSerializer" type: "" syntax: "public CosmosClientBuilder customItemSerializer(CosmosItemSerializer customItemSerializer)" desc: "Sets a custom serializer that should be used for conversion between POJOs and Json payload stored in the Cosmos DB service. The custom serializer can also be specified in request options. If defined here and in request options the serializer defined in request options will be used." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.directMode()" fullName: "com.azure.cosmos.CosmosClientBuilder.directMode()" name: "directMode()" nameWithType: "CosmosClientBuilder.directMode()" summary: "Sets the default DIRECT connection configuration to be used." syntax: "public CosmosClientBuilder directMode()" desc: "Sets the default DIRECT connection configuration to be used.\nBy default, the builder is initialized with directMode()" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.directMode(com.azure.cosmos.DirectConnectionConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig)" name: "directMode(DirectConnectionConfig directConnectionConfig)" nameWithType: "CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig)" summary: "Sets the DIRECT connection configuration to be used." parameters: - description: "direct connection configuration" name: "directConnectionConfig" type: "" syntax: "public CosmosClientBuilder directMode(DirectConnectionConfig directConnectionConfig)" desc: "Sets the DIRECT connection configuration to be used.\nBy default, the builder is initialized with directMode()" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.directMode(com.azure.cosmos.DirectConnectionConfig,com.azure.cosmos.GatewayConnectionConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)" name: "directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)" nameWithType: "CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)" summary: "Sets the DIRECT connection configuration to be used." parameters: - description: "direct connection configuration to be used" name: "directConnectionConfig" type: "" - description: "gateway connection configuration to be used" name: "gatewayConnectionConfig" type: "" syntax: "public CosmosClientBuilder directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)" desc: "Sets the DIRECT connection configuration to be used. gatewayConnectionConfig - represents basic configuration to be used for gateway client.\nEven in direct connection mode, some of the meta data operations go through gateway client,\nSetting gateway connection config in this API doesn't affect the connection mode, which will be Direct in this case." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.endToEndOperationLatencyPolicyConfig(com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.endToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig)" name: "endToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig)" nameWithType: "CosmosClientBuilder.endToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig)" summary: "Sets the on the client" parameters: - description: "the " name: "cosmosEndToEndOperationLatencyPolicyConfig" type: "" syntax: "public CosmosClientBuilder endToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig)" desc: "Sets the on the client" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.endpoint(java.lang.String)" fullName: "com.azure.cosmos.CosmosClientBuilder.endpoint(String endpoint)" name: "endpoint(String endpoint)" nameWithType: "CosmosClientBuilder.endpoint(String endpoint)" summary: "Sets the Azure Cosmos DB endpoint the SDK will connect to" parameters: - description: "the service endpoint" name: "endpoint" type: "String" syntax: "public CosmosClientBuilder endpoint(String endpoint)" desc: "Sets the Azure Cosmos DB endpoint the SDK will connect to" returns: description: "current Builder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)" name: "endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)" nameWithType: "CosmosClientBuilder.endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)" summary: "Sets the flag to enable endpoint discovery for geo-replicated database accounts." parameters: - description: "true if EndpointDiscovery is enabled." name: "endpointDiscoveryEnabled" type: "" syntax: "public CosmosClientBuilder endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)" desc: "Sets the flag to enable endpoint discovery for geo-replicated database accounts.\n\nWhen EnableEndpointDiscovery is true, the SDK will automatically discover the current write and read regions to ensure requests are sent to the correct region based on the capability of the region and the user's preference.\n\nThe default value for this property is true indicating endpoint discovery is enabled." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.excludedRegionsSupplier(java.util.function.Supplier)" fullName: "com.azure.cosmos.CosmosClientBuilder.excludedRegionsSupplier(Supplier excludedRegionsSupplier)" name: "excludedRegionsSupplier(Supplier excludedRegionsSupplier)" nameWithType: "CosmosClientBuilder.excludedRegionsSupplier(Supplier excludedRegionsSupplier)" summary: "Sets a \"> which returns a instance when is invoked." parameters: - description: "the supplier which returns a CosmosExcludedRegions instance." name: "excludedRegionsSupplier" type: "Supplier<>" syntax: "public CosmosClientBuilder excludedRegionsSupplier(Supplier excludedRegionsSupplier)" desc: "Sets a \"> which returns a instance when is invoked. The request will not be routed to regions present in for hedging scenarios and retry scenarios for the workload executed through this instance of / ." returns: description: "current CosmosClientBuilder." type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.gatewayMode()" fullName: "com.azure.cosmos.CosmosClientBuilder.gatewayMode()" name: "gatewayMode()" nameWithType: "CosmosClientBuilder.gatewayMode()" summary: "Sets the default GATEWAY connection configuration to be used." syntax: "public CosmosClientBuilder gatewayMode()" desc: "Sets the default GATEWAY connection configuration to be used." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.gatewayMode(com.azure.cosmos.GatewayConnectionConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)" name: "gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)" nameWithType: "CosmosClientBuilder.gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)" summary: "Sets the GATEWAY connection configuration to be used." parameters: - description: "gateway connection configuration" name: "gatewayConnectionConfig" type: "" syntax: "public CosmosClientBuilder gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)" desc: "Sets the GATEWAY connection configuration to be used." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.key(java.lang.String)" fullName: "com.azure.cosmos.CosmosClientBuilder.key(String key)" name: "key(String key)" nameWithType: "CosmosClientBuilder.key(String key)" summary: "Sets either a master or readonly key used to perform authentication for accessing resource." parameters: - description: "master or readonly key" name: "key" type: "String" syntax: "public CosmosClientBuilder key(String key)" desc: "Sets either a master or readonly key used to perform authentication for accessing resource." returns: description: "current Builder." type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.multipleWriteRegionsEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)" name: "multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)" nameWithType: "CosmosClientBuilder.multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)" summary: "Sets the flag to enable writes on any regions for geo-replicated database accounts in the Azure Cosmos DB service." parameters: - description: "flag to enable writes on any regions for geo-replicated\n database accounts." name: "multipleWriteRegionsEnabled" type: "" syntax: "public CosmosClientBuilder multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)" desc: "Sets the flag to enable writes on any regions for geo-replicated database accounts in the Azure Cosmos DB service.\n\nWhen the value of this property is true, the SDK will direct write operations to available writable regions of geo-replicated database account. Writable regions are ordered by PreferredRegions property. Setting the property value to true has no effect until EnableMultipleWriteRegions in DatabaseAccount is also set to true.\n\nDEFAULT value is true indicating that writes are directed to available writable regions of geo-replicated database account." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.nonIdempotentWriteRetryOptions(com.azure.cosmos.NonIdempotentWriteRetryOptions)" fullName: "com.azure.cosmos.CosmosClientBuilder.nonIdempotentWriteRetryOptions(NonIdempotentWriteRetryOptions options)" name: "nonIdempotentWriteRetryOptions(NonIdempotentWriteRetryOptions options)" nameWithType: "CosmosClientBuilder.nonIdempotentWriteRetryOptions(NonIdempotentWriteRetryOptions options)" summary: "Enables automatic retries for write operations even when the SDK can't guarantee that they are idempotent." parameters: - description: "the options controlling whether non-idempotent write operations should be retried and whether\n trackingIds can be used." name: "options" type: "" syntax: "public CosmosClientBuilder nonIdempotentWriteRetryOptions(NonIdempotentWriteRetryOptions options)" desc: "Enables automatic retries for write operations even when the SDK can't guarantee that they are idempotent. This is the default behavior for the entire Cosmos client - the policy can be overridden for individual operations in the request options.\n> NOTE: the setting on the CosmosClientBuilder will determine the default behavior for Create, Replace, Upsert and Delete operations. It can be overridden on per-request base in the request options. For patch operations by default (unless overridden in the request options) retries are always disabled by default.\n\\- Create: retries can result in surfacing (more) 409-Conflict requests to the application when a retry tries to create a document that the initial attempt successfully created. When enabling useTrackingIdPropertyForCreateAndReplace this can be avoided for 409-Conflict caused by retries.\n\\- Replace: retries can result in surfacing (more) 412-Precondition failure requests to the application when a replace operations are using a pre-condition check (etag) and a retry tries to update a document that the initial attempt successfully updated (causing the etag to change). When enabling useTrackingIdPropertyForCreateAndReplace this can be avoided for 412-Precondition failures caused by retries.\n\\- Delete: retries can result in surfacing (more) 404-NotFound requests when a delete operation is retried and the initial attempt succeeded. Ideally, write retries should only be enabled when applications can gracefully handle 404 - Not Found.\n\\- Upsert: retries can result in surfacing a 200 - looking like the document was updated when actually the document has been created by the initial attempt - so logically within the same operation. This will only impact applications who have special casing for 201 vs. 200 for upsert operations.\nPatch: retries for patch can but will not always be idempotent - it completely depends on the patch operations being executed and the precondition filters being used. Before enabling write retries for patch this needs to be carefully reviewed and tests - which is wht retries for patch can only be enabled on request options - any CosmosClient wide configuration will be ignored.\nBulk/Delete by PK/Transactional Batch/Stored Procedure execution: No automatic retries are supported." returns: description: "the CosmosItemRequestOptions" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.openConnectionsAndInitCaches(com.azure.cosmos.CosmosContainerProactiveInitConfig)" fullName: "com.azure.cosmos.CosmosClientBuilder.openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)" name: "openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)" nameWithType: "CosmosClientBuilder.openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)" summary: "Sets the which enable warming up of caches and connections associated with containers obtained from to replicas obtained from the first *k* preferred regions where *k* evaluates to ." parameters: - description: "which encapsulates a list of container identities and no of\n proactive connection regions" name: "proactiveContainerInitConfig" type: "" syntax: "public CosmosClientBuilder openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)" desc: "Sets the which enable warming up of caches and connections associated with containers obtained from to replicas obtained from the first *k* preferred regions where *k* evaluates to .\n\nUse the class to instantiate class" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.permissions(java.util.List)" fullName: "com.azure.cosmos.CosmosClientBuilder.permissions(List permissions)" name: "permissions(List permissions)" nameWithType: "CosmosClientBuilder.permissions(List permissions)" summary: "Sets the permission list, which contains the resource tokens needed to access resources." parameters: - description: "Permission list for authentication." name: "permissions" type: "List<>" syntax: "public CosmosClientBuilder permissions(List permissions)" desc: "Sets the permission list, which contains the resource tokens needed to access resources." returns: description: "current Builder." type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(java.util.List)" fullName: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(List preferredRegions)" name: "preferredRegions(List preferredRegions)" nameWithType: "CosmosClientBuilder.preferredRegions(List preferredRegions)" summary: "Sets the preferred regions for geo-replicated database accounts." parameters: - description: "the list of preferred regions." name: "preferredRegions" type: "List<String>" syntax: "public CosmosClientBuilder preferredRegions(List preferredRegions)" desc: "Sets the preferred regions for geo-replicated database accounts. For example, \"East US\" as the preferred region.\n\nWhen EnableEndpointDiscovery is true and PreferredRegions is non-empty, the SDK will prefer to use the regions in the container in the order they are specified to perform operations.\n\nIf EnableEndpointDiscovery is set to false, this property is ignored." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.readRequestsFallbackEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)" name: "readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)" nameWithType: "CosmosClientBuilder.readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)" summary: "Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service." parameters: - description: "flag to enable reads to go to multiple regions configured on an account of\n Azure Cosmos DB service." name: "readRequestsFallbackEnabled" type: "" syntax: "public CosmosClientBuilder readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)" desc: "Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.\n\nDEFAULT value is true.\n\nIf this property is not set, the default is true for all Consistency Levels other than Bounded Staleness, The default is false for Bounded Staleness. 1. is true 2. the Azure Cosmos DB account has more than one region" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.resourceToken(java.lang.String)" fullName: "com.azure.cosmos.CosmosClientBuilder.resourceToken(String resourceToken)" name: "resourceToken(String resourceToken)" nameWithType: "CosmosClientBuilder.resourceToken(String resourceToken)" summary: "Sets a resource token used to perform authentication for accessing resource." parameters: - description: "resourceToken for authentication" name: "resourceToken" type: "String" syntax: "public CosmosClientBuilder resourceToken(String resourceToken)" desc: "Sets a resource token used to perform authentication for accessing resource." returns: description: "current Builder." type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean)" fullName: "com.azure.cosmos.CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)" name: "sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)" nameWithType: "CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)" summary: "Session capturing is enabled by default for ." parameters: - description: "session capturing override" name: "sessionCapturingOverrideEnabled" type: "" syntax: "public CosmosClientBuilder sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)" desc: "Session capturing is enabled by default for . For other consistency levels, it is not needed, unless if you need occasionally send requests with Session Consistency while the client is not configured in session.\n\nenabling Session capturing for Session mode has no effect." returns: description: "current cosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.sessionRetryOptions(com.azure.cosmos.SessionRetryOptions)" fullName: "com.azure.cosmos.CosmosClientBuilder.sessionRetryOptions(SessionRetryOptions sessionRetryOptions)" name: "sessionRetryOptions(SessionRetryOptions sessionRetryOptions)" nameWithType: "CosmosClientBuilder.sessionRetryOptions(SessionRetryOptions sessionRetryOptions)" summary: "Sets the instance on the client." parameters: - description: "The instance." name: "sessionRetryOptions" type: "" syntax: "public CosmosClientBuilder sessionRetryOptions(SessionRetryOptions sessionRetryOptions)" desc: "Sets the instance on the client.\n\nThis setting helps in optimizing retry behavior associated with `NOT_FOUND / READ_SESSION_NOT_AVAILABLE` or `404 / 1002` scenarios which happen when the targeted consistency used by the request is *Session Consistency* and a request goes to a region that does not have recent enough data which the request is looking for.\n\nDISCLAIMER: Setting will modify retry behavior for all operations or workloads executed through this instance of the client.\n\nFor multi-write accounts:\n\n * For a read request going to a local read region, it is possible to optimize availability by having the request be retried on a different write region since the other write region might have more upto date data.\n * For a read request going to a local write region, it could help to switch to a different write region right away provided the local write region does not have the most up to date data.\n * For a write request going to a local write region, it could help to switch to a different write region right away provided the local write region does not have the most up to date data.\n\nFor single-write accounts:\n\n * If a read request goes to a local read region, it helps to switch to the write region quicker.\n * If a read request goes to a write region, the setting does not matter since the write region in a single-write account has the most up to date data.\n * For a write to a write region in a single-write account, `READ_SESSION_NOT_AVAILABLE` errors do not apply since the write-region always has the most recent version of the data and all writes go to the primary replica in this region. Therefore, replication lags causing errors is not applicable here.\n\nAbout region switch hints:\n\n * In order to prioritize the local region for retries, use the hint \n * In order to move retries to a different / remote region quicker, use the hint \n\nOperations supported:\n\n * Read\n * Query\n * Create\n * Replace\n * Upsert\n * Delete\n * Patch\n * Batch\n * Bulk" returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.throttlingRetryOptions(com.azure.cosmos.ThrottlingRetryOptions)" fullName: "com.azure.cosmos.CosmosClientBuilder.throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)" name: "throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)" nameWithType: "CosmosClientBuilder.throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)" summary: "Sets the retry policy options associated with the DocumentClient instance." parameters: - description: "the RetryOptions instance." name: "throttlingRetryOptions" type: "" syntax: "public CosmosClientBuilder throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)" desc: "Sets the retry policy options associated with the DocumentClient instance.\n\nProperties in the RetryOptions class allow application to customize the built-in retry policies. This property is optional. When it's not set, the SDK uses the default values for configuring the retry policies. See RetryOptions class for more details." returns: description: "current CosmosClientBuilder" type: "" - uid: "com.azure.cosmos.CosmosClientBuilder.userAgentSuffix(java.lang.String)" fullName: "com.azure.cosmos.CosmosClientBuilder.userAgentSuffix(String userAgentSuffix)" name: "userAgentSuffix(String userAgentSuffix)" nameWithType: "CosmosClientBuilder.userAgentSuffix(String userAgentSuffix)" summary: "sets the value of the user-agent suffix." parameters: - description: "The value to be appended to the user-agent header, this is\n used for monitoring purposes." name: "userAgentSuffix" type: "String" syntax: "public CosmosClientBuilder userAgentSuffix(String userAgentSuffix)" desc: "sets the value of the user-agent suffix." returns: description: "current CosmosClientBuilder" type: "" type: "class" desc: "Helper class to build and instances as logical representation of the Azure Cosmos database service.\n\nCosmosAsyncClient and CosmosClient are thread-safe. It's recommended to maintain a single instance of CosmosClient or CosmosAsyncClient per lifetime of the application which enables efficient connection management and performance. CosmosAsyncClient and CosmosClient initializations are heavy operations - don't use initialization CosmosAsyncClient or CosmosClient instances as credentials or network connectivity validations.\n\nWhen building client, endpoint() and key() are mandatory APIs, without these the initialization will fail.\n\nThough consistencyLevel is not mandatory, but we strongly suggest to pay attention to this API when building client. By default, account consistency level is used if none is provided.\n\nBy default, direct connection mode is used if none specified.\n\n```java\nBuilding Cosmos Async Client minimal APIs (without any customized configurations)\n \n CosmosAsyncClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .buildAsyncClient();\n```\n\n```java\nBuilding Cosmos Async Client with customizations\n \n CosmosAsyncClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .directMode(directConnectionConfig, gatewayConnectionConfig)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .contentResponseOnWriteEnabled(true)\n .userAgentSuffix(\"my-application1-client\")\n .preferredRegions(Collections.singletonList(\"West US\", \"East US\"))\n .buildAsyncClient();\n```\n\n```java\nBuilding Cosmos Sync Client minimal APIs (without any customized configurations)\n \n CosmosClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .buildClient();\n```\n\n```java\nBuilding Cosmos Sync Client with customizations\n \n CosmosClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .directMode(directConnectionConfig, gatewayConnectionConfig)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .contentResponseOnWriteEnabled(true)\n .userAgentSuffix(\"my-application1-client\")\n .preferredRegions(Collections.singletonList(\"West US\", \"East US\"))\n .buildClient();\n```" implements: - "<>" - "<>" - "<>" metadata: {} package: "com.azure.cosmos" artifact: com.azure:azure-cosmos:4.63.3