How to use corporate proxy in the OpenIdConnectConfigurationRetriever.GetAsync call?

317 Views Asked by At

I am very new to all things Microsoft and Azure and am not even sure that I have selected the correct tags for the question.

In the Azure service source code (that I have inherited from a colleague) the following code fails with "Host not found" because the request is not going through the corporate web proxy (when I run the code at home network, then the call succeeds):

OpenIdConnectConfiguration openidConfiguration = 
    OpenIdConnectConfigurationRetriever.GetAsync(metadataEndpoint, CancellationToken.None).Result;

If I create a WebProxy object by calling:

WebProxy proxy = new WebProxy("10.xxx.xxx.xxx", 8080);

then how could I please pass it to the OpenIdConnectConfigurationRetriever?

Should I maybe switch to using another .GetAsync method?

public static Task<OpenIdConnectConfiguration> 
    GetAsync(string address, HttpClient httpClient, CancellationToken cancel);

Or should I maybe use a BackchannelHttpHandler (not sure what it is, comes up during my searches)

1

There are 1 best solutions below

1
Alexander Farber On BEST ANSWER

Solved that by:

WebRequest.DefaultWebProxy = new WebProxy("http://10.xxx.xxx.xxx:8080", true);