Azure appservice cannot reach out

Ahmad Jaber 0 Reputation points
2024-04-30T06:05:31.93+00:00

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);

   }
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,001 questions
{count} votes