1

I have been working all night trying to get a SQL Server connection from either a C# Lambda function(.Core) or an AWS EC2 instance with no luck.

I shows : Unhandled Exception: System.Data.SqlClient.SqlException: 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: TCP Provider, error: 40 - Could not open a connection to SQL Server)

Please Help..

2
  • You will need to check on the security group/subnet in which your Lambda function is running and if your DB has the relevant inbound rules to allow traffic from the above subnet/securitygroup. Commented Dec 23, 2016 at 12:09
  • Thanks for your reply.. but We have opened all ports for Sql and Lambda. RDS ,Lambda and Sql are in same subnet. Commented Dec 26, 2016 at 6:54

1 Answer 1

1

Issue Resolved. Hopefully my solution may help to others.....

The issue was related to the SqlClient version on Linux as Lambda works in linux environment. we changed the reference from "System.Data.SqlClient": "4.3.0" to "System.Data.SqlClient": "4.1.0-rc2-24027" in project.json file

Thanks.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. I changed to 4.1.0 in nuget manager and it works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.