The remote name could not be resolved Azure

The remote name could not be resolved azure

In this Azure tutorial, we will discuss how to fix the error. The remote name could not be resolved in Azure, which I got while creating Intelligent C# Apps With Azure Cognitive Services.

The remote name could not be resolved Azure

Recently, while working with Azure Cognitive Services, I got the error The remote name could not be resolved: ‘eastus.api.cognitive.microsoft.com’.

As part of the requirement, I have created an Azure Cognitive Services Computer Vision API in the Azure Portal and then copied the Key and the endpoint URL value of the Azure Cognitive Services Computer Vision API. Then, the requirement was to create a Windows application.

I have created a Windows application using Visual Studio 2019 and added the required code. So, the main functionality was to upload an image on the Windows form and then click on the Submit button. Then, the API will analyze the image and provide you a detailed description of different parameters.

The endpoint URL for my Azure Cognitive Services Computer Vision API was as below

https://eastus.api.cognitive.microsoft.com/vision/v3.0/analyze

When I pressed F5 to run the Windows Application project, I got the error The remote name could not be resolved: ‘eastus.api.cognitive.microsoft.com’.

The complete error message was as below

System.Net.Http.HttpRequestException
HResult=0x80131500
Message=An error occurred while sending the request.
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at MyInteligentApp.Form1.<MakeAnalaysisRequest>d__5.MoveNext() in C:\Users\Bijay\source\MyInteligentApp\MyInteligentApp\Form1.cs:line 67 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at MyInteligentApp.Form1.d__7.MoveNext() in C:\Users\Bijay\source\MyInteligentApp\MyInteligentApp\Form1.cs:line 90

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
WebException: The remote name could not be resolved: ‘eastus.api.cognitive.microsoft.com’

The remote name could not be resolved Azure [Solved]

I have tried a couple of ways to fix this issue. But, there is one way that worked for me. Below is the change you need to do to fix this issue. You need to add the below lines of code in your App.config or Web.config file to fix this issue.

Open the App.config file and add the below lines of code

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
  </defaultProxy>
</system.net>

Earlier, Before Adding the above code, the App. config file was looking like the below

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
</configuration>

After adding the complete code, The App.config file will look like below

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
  </defaultProxy>
</system.net>
</configuration>

You can see it here below

unresolvablehostname. http request failed with status code 'nameresolutionfailure' and status message: 'the remote name could not be resolved:

After running the Windows application, I got the expected output without issues. You can see it below

http request failed with status code 'nameresolutionfailure' and status message: 'the remote name could not be resolved:

This is how I can fix the error. The remote name could not be resolved while working with Azure Cognitive Services Computer Vision API.

You may also like following the Below Articles

Wrapping Up

Well, in this article, we discussed how to fix the error. The remote name could not be resolved. I hope this will help you to fix your issue as well !!!