diff --git a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs index dfd221149d..a4a4542260 100644 --- a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs +++ b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs @@ -97,11 +97,19 @@ public static CosmosHttpClient CreateWithConnectionPolicy( public static HttpMessageHandler CreateHttpClientHandler(int gatewayModeMaxConnectionLimit, IWebProxy webProxy) { // https://docs.microsoft.com/en-us/archive/blogs/timomta/controlling-the-number-of-outgoing-connections-from-httpclient-net-core-or-full-framework - return new HttpClientHandler + try { - Proxy = webProxy, - MaxConnectionsPerServer = gatewayModeMaxConnectionLimit - }; + return new HttpClientHandler + { + Proxy = webProxy, + MaxConnectionsPerServer = gatewayModeMaxConnectionLimit + }; + } + catch (PlatformNotSupportedException) + { + // Proxy and MaxConnectionsPerServer are not supported on some platforms. + return new HttpClientHandler(); + } } private static HttpMessageHandler CreateHttpMessageHandler(