Azure host name resolution inside Web App

azuredomain-name-system

In the last couple of days we have some problem on our Azure Web App (S3 WebSite hosted in North Europe data center) when resolving host names.

We have created a very simple .aspx page that try to resolve google.com and sometime we receive the correct ip other times we get this error:

System.Net.Sockets.SocketException (0x80004005): No such host is known
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean
includeIPv6) at System.Net.Dns.Resolve(String hostName) at
ASP._diagnostics_dns_aspx.HostName2IP(String hostname) at
ASP._diagnostics_dns_aspx.Resolve(Object sender, EventArgs e)

The same problems occurs when resolving internal azure host names (*.cloudapp.azure.com) or other host names (microsoft.com, …).

Our suspect is that one of the instance where the app is hosted (we currently have 2 instances) have the dns resolution broken.

You can see the full aspx page code here: https://gist.github.com/davideicardi/6d3f5bf45efaeea0e2a03cba58beec5f

But basically it use the following code to resolve the requested host name:

  private string HostName2IP(string hostname)
  {
      var iphost = System.Net.Dns.GetHostEntry(hostname);
      var addresses = iphost.AddressList;
      var addressList = new System.Text.StringBuilder( );
      foreach(var address in addresses)
      {
          addressList.Append("IP Address: ");
          addressList.Append(address.ToString( ));
          addressList.Append(";");
      }
      return addressList.ToString( );
  }

Any idea? It is possible that we have broken some configuration or there is a problem in Azure?

UPDATE:
If I use [System.Net.Dns]::GetHostEntry("google.com") or using nslookup inside the Kudu PowerShell console the name is always resolved. Seems to be a problem related to my website only. I have tried on both instances.

Best Answer

I have an open ticket with MS that seems to confirm that it was bug on Azure side.