Can not connect from ACI to Azure SQL Server

alireza yadegari 0 Reputation points
2024-03-05T10:29:21.2+00:00

I have a C# application in .Net 8 that uses the Entity framework to connect to the SQL database. I am using the SQL Authentication in the connection string. In my local I run the container I can connect to the Azure SQL Server and everything is good but when I run the container inside the Azure Container Instance with the exact same image and environment variable I get this error when i want to connect to the exact same database that I connect in my local . I white listed my Azure Container Instance public Id and my local also I checked the "Allow Azure Services and Instances to this Server".

"

 Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HN1SVGHL7U9F", Request id "0HN1SVGHL7U9F:00000001": An unhandled exception was thrown by the application.
      Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
       ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer.
       ---> System.Net.Sockets.SocketException (104): Connection reset by peer"
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
669 questions
{count} votes