Azure appservice cannot reach out
Hi!
I have an App Service in Azure, when I test the service locally, it is working without any issue, when I deployed to Azure I get the error below:
"System.Net.Http.HttpRequestException: No such host is known. (api-m.sandbox...com:443) ---> System.Net.Sockets.SocketException (11001): No such host is known. at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)"
I dont thinks it is a code issue, but the constructor is below :
public MyConstructor(IHttpClientFactory httpClientFactory)
{
HttpClientHandler handler = new()
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
};
HttpClient = new HttpClient(handler)
{
BaseAddress = new Uri("https://api-m.sandbox....com:443/")
};
HttpClient namedClient = httpClientFactory.CreateClient("paypal_clinet");
HttpClient.DefaultRequestHeaders.Clear();
foreach (var header in namedClient.DefaultRequestHeaders)
{
HttpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
}
ClientExecuter = new RestClientExecuter(HttpClient);
}