From e65d0fc2679a0d4b27c0ef796cf8d82298cb8d95 Mon Sep 17 00:00:00 2001 From: rajithaaluri Date: Wed, 29 Jan 2025 09:41:36 -0600 Subject: [PATCH] ConnectionMode is fetched from configuration instead of using Direct mode always --- .../Features/Storage/FhirCosmosClientInitializer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/FhirCosmosClientInitializer.cs b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/FhirCosmosClientInitializer.cs index df1344f058..edd3458885 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/FhirCosmosClientInitializer.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/FhirCosmosClientInitializer.cs @@ -131,8 +131,16 @@ private CosmosClient CreateCosmosClientInternal(CosmosDataStoreConfiguration con new CosmosClientBuilder(host, _cosmosAccessTokenProviderFactory.Invoke().TokenCredential) : new CosmosClientBuilder(host, key); + if (configuration.ConnectionMode == ConnectionMode.Gateway) + { + builder.WithConnectionModeGateway(); + } + else + { + builder.WithConnectionModeDirect(enableTcpConnectionEndpointRediscovery: true); + } + builder - .WithConnectionModeDirect(enableTcpConnectionEndpointRediscovery: true) .WithCustomSerializer(new FhirCosmosSerializer(_logger)) .WithThrottlingRetryOptions(TimeSpan.FromSeconds(configuration.RetryOptions.MaxWaitTimeInSeconds), configuration.RetryOptions.MaxNumberOfRetries) .AddCustomHandlers(requestHandlers.ToArray());