0

I am trying to connect to an sql server from my windows container. It all works fine when I spin up the container locally on my machine, or on an azure vm, and I can connect to the azure sql server but the connection fails when I deploy the container to azure container instance. The sql server firewall is open 0.0.0.0 to 255.255.255.255.

I believe that I have narrowed it down to a DNS issue because when I try to lookup the sql server or any host for that matter I get a "No such host is known". There is a known 30 second startup delay but it still does not resolve after multiple retries.

IPHostEntry ipHostInfo = Dns.GetHostEntry("mysqlserver.database.windows.net");  
IPAddress ipAddress = ipHostInfo.AddressList[0];  
Console.WriteLine($"Ipaddress {ipAddress.MapToIPv4()}");
  • Some questions. Where do you look up the SQL server and host and then you got the error "No such host is known"? And what steps do you do when you run the image locally and in Azure container instance? – Charles Xu May 02 '19 at 12:41

1 Answers1

2

Further to my original question I have come up with two options to resolve this issue.

  1. If you are working with a .netcore project then set build target to linux and deploy to a linux container/environment. The DNS lookup then works as it should.

  2. If you are stuck with a non .netcore project then run a powershell script on the container bootstrap to force the container to use a public DNS such as Google (8.8.8.8).

$nic = Get-NetAdapter
Set-DnsClientServerAddress -InterfaceIndex $nic.IfIndex -ServerAddresses ('8.8.8.8')