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,407 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 20,856 Reputation points
    2024-05-01T09:06:09.33+00:00

    @Ahmad Jaber Thanks for asking question!

    The error message you are seeing indicates that the host name api-m.sandbox...com is not being resolved by the DNS server.

    This could be caused by a few different issues. Here are some steps you can take to troubleshoot the issue:

    1. Check the DNS settings: Mostly the issue would have caused due to DNS where the name was not resolved once. Make sure that the DNS settings for your custom domain are set up correctly. Check that the DNS records are pointing to the correct IP address and that there are no typos or errors in the settings.
    2. Check the firewall settings: Make sure that the firewall settings for your App Service are set up correctly. Check that the firewall is not blocking traffic to the host name api-m.sandbox...com.
    3. Check the network settings: Make sure that the network settings for your App Service are set up correctly. Check that the App Service is not using a virtual network that is blocking traffic to the host name api-m.sandbox...com.
    4. If connecting to SQL DB or using Azure storage account verify connection string is correct. see- this discussion.

    Let us know.

    0 comments No comments