2

I get the following error when trying to connect to my SQL Server Express RDS instance over AWS Lambda using System.Data.SqlClient:

"errorType": "PlatformNotSupportedException",
"errorMessage": "Operation is not supported on this platform.",
"stackTrace": [
"at System.Runtime.InteropServices.OSPlatform.get_Windows()",
"at System.Data.SqlClient.SNI.SNITCPHandle.d__22.MoveNext()"
]

I build the deploy package using Amazon.Lambda.Tools. Running the function and connecting to the database from local works fine, but fails when trying to run it on AWS Lambda.

Here is my project.json:

{
"version": "1.0.0-*",
"description": "AWS lambda Console Application",
"authors": [ "" ],
"packOptions": {
    "tags": [],
    "projectUrl": "",
    "licenseUrl": ""
},
"buildOptions": {
    "emitEntryPoint": true
},
"dependencies": {
    "Microsoft.NETCore.App": {
    "type": "platform",
    "version": "1.0.0"
    },
    "Newtonsoft.Json": "9.0.1",
    "Amazon.Lambda.Core": "1.0.0*",
    "Amazon.Lambda.Serialization.Json": "1.0.1",
    "Amazon.Lambda.Tools": {
    "type": "build",
    "version": "1.0.0-preview1"
    },
    "Dapper": "1.50.2",
    "System.Data.SqlClient": "4.3.0"
},
"tools": {
    "Amazon.Lambda.Tools": "1.0.0-preview1"
}, 
"commands": {
    "AwsLambda": "run"
},
"frameworks": {
    "netcoreapp1.0": {
        "imports": "dnxcore50"
    }
}
}
1
  • Hi @torryt, pls how did you fix this? Commented Feb 20, 2017 at 22:27

3 Answers 3

5

Had the same problem and for me just changing

"System.Data.SqlClient": "4.3.0"

to

"System.Data.SqlClient": "4.1.0"

worked for me. I did not have to change the NetCore.App dependencies.

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

Comments

2

Explicitly add reference to

"System.Data.SqlClient": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0"

solves the problem.

1 Comment

We had been pulling our hair out, over this issue. Finally for the heck of it, we tried your suggestion, and lo and behold, it actually worked! Super annoying issue, but thank god we found a solution.
1

Can you try to change

"System.Data.SqlClient": "4.3.0"

to

"System.Data.SqlClient": "4.1.0"

and change

"dependencies": {
    "Microsoft.NETCore.App": {
    "type": "platform",
    "version": "1.0.0"
    },

to

"dependencies": {
    "Microsoft.NETCore.App": {
    "type": "platform",
    "version": "1.0.1"
    },

Comments

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.