In previous .Net console applications we can avoid proxy 407 errors by including the following in app.config:
<system.net>
<defaultProxy useDefaultCredentials="true"/>
</system.net>
.Net Core console app does not have app.config - how can we do the same?
Specifically for an Azure DocumentDB DocumentClient.
It looks like that for now Azure-oriented team didn't implement such feature. Here is a link to recent github issue for Azure AD library, which states that
- Currently ADAL for .NET doesn’t support
WebProxyconfiguration.- Please configure proxy at the system level.
Httpclientused by Adal should be able to use it.- Production team has planned to add this function in future version, but currently they don’t have estimation time.
As far as one can see, there is no such feature available in Microsoft.Azure.Documents.Client namespace or in Microsoft.Azure.Documents namespace, so for now you have to resolve it on system level. You can probably create a github issue or contact the team on MSDN or by email.
As for general .Net Core app, you can use the HttpClientHandler class' DefaultProxyCredentials property, so the code will be like this:
var handler = new HttpClientHandler { UseDefaultCredentials = true };
using (var client = new HttpClient(handler))
{
// http call here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With