azure-docs-sdk-java/docs-ref-autogen/com.azure.cosmos.CosmosClie...

491 строка
58 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.cosmos.CosmosClientBuilder"
fullName: "com.azure.cosmos.CosmosClientBuilder"
name: "CosmosClientBuilder"
nameWithType: "CosmosClientBuilder"
summary: "Helper class to build <xref uid=\"com.azure.cosmos.CosmosAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosAsyncClient\"></xref> and <xref uid=\"com.azure.cosmos.CosmosClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosClient\"></xref> instances as logical representation of the Azure Cosmos database service."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public class **CosmosClientBuilder**</br> implements <xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;, <xref href=\"com.azure.core.client.traits.AzureKeyCredentialTrait?alt=com.azure.core.client.traits.AzureKeyCredentialTrait&text=AzureKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;, <xref href=\"com.azure.core.client.traits.EndpointTrait?alt=com.azure.core.client.traits.EndpointTrait&text=EndpointTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
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: "<xref href=\"com.azure.cosmos.CosmosOperationPolicy?alt=com.azure.cosmos.CosmosOperationPolicy&text=CosmosOperationPolicy\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.models.CosmosAuthorizationTokenResolver?alt=com.azure.cosmos.models.CosmosAuthorizationTokenResolver&text=CosmosAuthorizationTokenResolver\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)"
desc: "Sets the token resolver"
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.CosmosAsyncClient?alt=com.azure.cosmos.CosmosAsyncClient&text=CosmosAsyncClient\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.CosmosClient?alt=com.azure.cosmos.CosmosClient&text=CosmosClient\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.models.CosmosClientTelemetryConfig?alt=com.azure.cosmos.models.CosmosClientTelemetryConfig&text=CosmosClientTelemetryConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)"
desc: "Returns the client telemetry config instance for this builder"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref> to be used\nBy default, <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref> consistency will be used."
parameters:
- description: "<xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref>"
name: "desiredConsistencyLevel"
type: "<xref href=\"com.azure.cosmos.ConsistencyLevel?alt=com.azure.cosmos.ConsistencyLevel&text=ConsistencyLevel\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyLevel)"
desc: "Sets the <xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref> to be used\nBy default, <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref> consistency will be used."
returns:
description: "current Builder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 Cosmos<wbr>Item."
parameters:
- description: "a boolean indicating whether payload will be included in the response or not"
name: "contentResponseOnWriteEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref> to be used"
parameters:
- description: "<xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref>"
name: "credential"
type: "<xref href=\"com.azure.core.credential.AzureKeyCredential?alt=com.azure.core.credential.AzureKeyCredential&text=AzureKeyCredential\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder credential(AzureKeyCredential credential)"
desc: "Sets the <xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref> to be used"
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service."
parameters:
- description: "<xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service."
name: "credential"
type: "<xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder credential(TokenCredential credential)"
desc: "Sets the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> 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 <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> type.\n\n\n[identity and authentication]: https://aka.ms/azsdk/java/docs/identity"
returns:
description: "the updated CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.CosmosItemSerializer?alt=com.azure.cosmos.CosmosItemSerializer&text=CosmosItemSerializer\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.DirectConnectionConfig?alt=com.azure.cosmos.DirectConnectionConfig&text=DirectConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.DirectConnectionConfig?alt=com.azure.cosmos.DirectConnectionConfig&text=DirectConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
- description: "gateway connection configuration to be used"
name: "gatewayConnectionConfig"
type: "<xref href=\"com.azure.cosmos.GatewayConnectionConfig?alt=com.azure.cosmos.GatewayConnectionConfig&text=GatewayConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosEndToEndOperationLatencyPolicyConfig\"></xref> on the client"
parameters:
- description: "the <xref uid=\"com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosEndToEndOperationLatencyPolicyConfig\"></xref>"
name: "cosmosEndToEndOperationLatencyPolicyConfig"
type: "<xref href=\"com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig?alt=com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig&text=CosmosEndToEndOperationLatencyPolicyConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder endToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig)"
desc: "Sets the <xref uid=\"com.azure.cosmos.CosmosEndToEndOperationLatencyPolicyConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosEndToEndOperationLatencyPolicyConfig\"></xref> on the client"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder endpoint(String endpoint)"
desc: "Sets the Azure Cosmos DB endpoint the SDK will connect to"
returns:
description: "current Builder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.excludedRegionsSupplier(java.util.function.Supplier<com.azure.cosmos.CosmosExcludedRegions>)"
fullName: "com.azure.cosmos.CosmosClientBuilder.excludedRegionsSupplier(Supplier<CosmosExcludedRegions> excludedRegionsSupplier)"
name: "excludedRegionsSupplier(Supplier<CosmosExcludedRegions> excludedRegionsSupplier)"
nameWithType: "CosmosClientBuilder.excludedRegionsSupplier(Supplier<CosmosExcludedRegions> excludedRegionsSupplier)"
summary: "Sets a <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Supplier<CosmosExcludedRegions>\"></xref> which returns a <xref uid=\"com.azure.cosmos.CosmosExcludedRegions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosExcludedRegions\"></xref> instance when <xref uid=\"java.util.function.Supplier.get*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Supplier#get()\"></xref> is invoked."
parameters:
- description: "the supplier which returns a <code>CosmosExcludedRegions</code> instance."
name: "excludedRegionsSupplier"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html\">Supplier</a>&lt;<xref href=\"com.azure.cosmos.CosmosExcludedRegions?alt=com.azure.cosmos.CosmosExcludedRegions&text=CosmosExcludedRegions\" data-throw-if-not-resolved=\"False\" />&gt;"
syntax: "public CosmosClientBuilder excludedRegionsSupplier(Supplier<CosmosExcludedRegions> excludedRegionsSupplier)"
desc: "Sets a <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Supplier<CosmosExcludedRegions>\"></xref> which returns a <xref uid=\"com.azure.cosmos.CosmosExcludedRegions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosExcludedRegions\"></xref> instance when <xref uid=\"java.util.function.Supplier.get*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Supplier#get()\"></xref> is invoked. The request will not be routed to regions present in <xref uid=\"com.azure.cosmos.CosmosExcludedRegions.getExcludedRegions()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosExcludedRegions#getExcludedRegions()\"></xref> for hedging scenarios and retry scenarios for the workload executed through this instance of <xref uid=\"com.azure.cosmos.CosmosClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosClient\"></xref> / <xref uid=\"com.azure.cosmos.CosmosAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosAsyncClient\"></xref>."
returns:
description: "current CosmosClientBuilder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.GatewayConnectionConfig?alt=com.azure.cosmos.GatewayConnectionConfig&text=GatewayConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)"
desc: "Sets the GATEWAY connection configuration to be used."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"com.azure.cosmos.NonIdempotentWriteRetryOptions?alt=com.azure.cosmos.NonIdempotentWriteRetryOptions&text=NonIdempotentWriteRetryOptions\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> which enable warming up of caches and connections associated with containers obtained from <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getCosmosContainerIdentities()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getCosmosContainerIdentities()\"></xref> to replicas obtained from the first *k* preferred regions where *k* evaluates to <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getProactiveConnectionRegionsCount()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getProactiveConnectionRegionsCount()\"></xref>."
parameters:
- description: "which encapsulates a list of container identities and no of\n proactive connection regions"
name: "proactiveContainerInitConfig"
type: "<xref href=\"com.azure.cosmos.CosmosContainerProactiveInitConfig?alt=com.azure.cosmos.CosmosContainerProactiveInitConfig&text=CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)"
desc: "Sets the <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> which enable warming up of caches and connections associated with containers obtained from <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getCosmosContainerIdentities()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getCosmosContainerIdentities()\"></xref> to replicas obtained from the first *k* preferred regions where *k* evaluates to <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getProactiveConnectionRegionsCount()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getProactiveConnectionRegionsCount()\"></xref>.\n\nUse the <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfigBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfigBuilder\"></xref> class to instantiate <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> class"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.permissions(java.util.List<com.azure.cosmos.models.CosmosPermissionProperties>)"
fullName: "com.azure.cosmos.CosmosClientBuilder.permissions(List<CosmosPermissionProperties> permissions)"
name: "permissions(List<CosmosPermissionProperties> permissions)"
nameWithType: "CosmosClientBuilder.permissions(List<CosmosPermissionProperties> permissions)"
summary: "Sets the permission list, which contains the resource tokens needed to access resources."
parameters:
- description: "Permission list for authentication."
name: "permissions"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<xref href=\"com.azure.cosmos.models.CosmosPermissionProperties?alt=com.azure.cosmos.models.CosmosPermissionProperties&text=CosmosPermissionProperties\" data-throw-if-not-resolved=\"False\" />&gt;"
syntax: "public CosmosClientBuilder permissions(List<CosmosPermissionProperties> permissions)"
desc: "Sets the permission list, which contains the resource tokens needed to access resources."
returns:
description: "current Builder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(java.util.List<java.lang.String>)"
fullName: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(List<String> preferredRegions)"
name: "preferredRegions(List<String> preferredRegions)"
nameWithType: "CosmosClientBuilder.preferredRegions(List<String> preferredRegions)"
summary: "Sets the preferred regions for geo-replicated database accounts."
parameters:
- description: "the list of preferred regions."
name: "preferredRegions"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>&gt;"
syntax: "public CosmosClientBuilder preferredRegions(List<String> 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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
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. <xref uid=\"com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#endpointDiscoveryEnabled\"></xref> is true 2. the Azure Cosmos DB account has more than one region"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder resourceToken(String resourceToken)"
desc: "Sets a resource token used to perform authentication for accessing resource."
returns:
description: "current Builder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref>."
parameters:
- description: "session capturing override"
name: "sessionCapturingOverrideEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)"
desc: "Session capturing is enabled by default for <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref>. 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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 <xref uid=\"com.azure.cosmos.SessionRetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SessionRetryOptions\"></xref> instance on the client."
parameters:
- description: "The <xref uid=\"com.azure.cosmos.SessionRetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SessionRetryOptions\"></xref> instance."
name: "sessionRetryOptions"
type: "<xref href=\"com.azure.cosmos.SessionRetryOptions?alt=com.azure.cosmos.SessionRetryOptions&text=SessionRetryOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder sessionRetryOptions(SessionRetryOptions sessionRetryOptions)"
desc: "Sets the <xref uid=\"com.azure.cosmos.SessionRetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SessionRetryOptions\"></xref> 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 <xref uid=\"com.azure.cosmos.SessionRetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SessionRetryOptions\"></xref> 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 <xref uid=\"com.azure.cosmos.SessionRetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SessionRetryOptions\"></xref> 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 <xref uid=\"com.azure.cosmos.CosmosRegionSwitchHint.LOCAL_REGION_PREFERRED\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosRegionSwitchHint#LOCAL_REGION_PREFERRED\"></xref>\n * In order to move retries to a different / remote region quicker, use the hint <xref uid=\"com.azure.cosmos.CosmosRegionSwitchHint.REMOTE_REGION_PREFERRED\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosRegionSwitchHint#REMOTE_REGION_PREFERRED\"></xref>\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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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 Document<wbr>Client instance."
parameters:
- description: "the RetryOptions instance."
name: "throttlingRetryOptions"
type: "<xref href=\"com.azure.cosmos.ThrottlingRetryOptions?alt=com.azure.cosmos.ThrottlingRetryOptions&text=ThrottlingRetryOptions\" data-throw-if-not-resolved=\"False\" />"
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: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- 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: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder userAgentSuffix(String userAgentSuffix)"
desc: "sets the value of the user-agent suffix."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "Helper class to build <xref uid=\"com.azure.cosmos.CosmosAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosAsyncClient\"></xref> and <xref uid=\"com.azure.cosmos.CosmosClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosClient\"></xref> 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:
- "<xref href=\"com.azure.core.client.traits.AzureKeyCredentialTrait?alt=com.azure.core.client.traits.AzureKeyCredentialTrait&text=AzureKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
- "<xref href=\"com.azure.core.client.traits.EndpointTrait?alt=com.azure.core.client.traits.EndpointTrait&text=EndpointTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
- "<xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
metadata: {}
package: "com.azure.cosmos"
artifact: com.azure:azure-cosmos:4.63.3