CosmosDB C# SDK ProyUrl missing

2019-08-25 01:49发布

I am working on a containerized micro-services project (docker) in .NET Core targeting Azure. So we are using Azure Cosmos DB, and the C# Cosmos DB SDK (v2.4 since v3 is only in preview) for the CoreSql Api.

During development, I am behind a proxy, so I need to specify the proxy url for everything going outside. It works fine with HttpClientHandler for any HttpClient.

Using Cosmos DB SDK, I however don't see how to set this up on my DocumentClient.

In the Azure Node SDK, I see I could just create a ConnectionPolicy and set the ProxyUrl property for this purpose: https://docs.microsoft.com/en-us/javascript/api/%40azure/cosmos/connectionpolicy?view=azure-node-latest#proxyurl

However, in the C# variant, no ProxyUrl: https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.client.connectionpolicy?view=azure-dotnet

Is there another way to set that? It is a missing feature in Cosmos DB SDK? Thanks! Eric

1条回答
甜甜的少女心
2楼-- · 2019-08-25 02:31

You can try setting in the config file like below:

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
        <proxy usesystemdefault="True" />
    </defaultProxy>
</system.net>

Alternatively ,you can use HttpMessageHandler class as mentioned by @Matias.

查看更多
登录 后发表回答