1 year ago
#280680
Anuj
Connect Azure Database through docker windows container
I have a .netframework 4.7.2 application with the azure database. I have created a docker windows container for this application. When I launch this application in the Docker container on my local machine, it gives an error:
[Win32Exception (0x80004005): The network path was not found]
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
ConnectionString:
connectionString="Data Source=tcp:servername.database.windows.net,1433;Database=databasename;User ID=testuser;Password=testpassword;Trusted_Connection=False;MultipleActiveResultSets=True;Encrypt=True" providerName="System.Data.SqlClient"
Docker File:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY ./bin/Release/Publish/ .
My IP Address is already added in the azure database and when I connect through the SQL management studio from the local machine it works without any issue. Also, It works fine with visual studio.
I believe my docker has internet access. When I ping google.com inside the docker container, it returns the result ping google
C:\inetpub\wwwroot>ping google.com
Pinging google.com [172.217.166.14] with 32 bytes of data:
Reply from 172.217.166.14: bytes=32 time=19ms TTL=118
Reply from 172.217.166.14: bytes=32 time=19ms TTL=118
Reply from 172.217.166.14: bytes=32 time=19ms TTL=118
Reply from 172.217.166.14: bytes=32 time=19ms TTL=118
Ping statistics for 172.217.166.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 19ms, Maximum = 19ms, Average = 19ms
C:\inetpub\wwwroot>
Can someone guide me on how can I connect my application to the Azure database inside the docker container?
sql-server
azure
docker
.net-4.8
windows-container
0 Answers
Your Answer