azure-functions-core-tools
azure-functions-core-tools copied to clipboard
`PlatformNotSupported_DataSqlClient` when running non-.NET function with SQL binding
Sample project to use as a repro : JsFunc.zip
- Start with basic JS function (Http trigger in my example case)
- Add SQL binding through
func extensions install --package Microsoft.Azure.WebJobs.Extensions.Sql --version 0.1.223-preview - Add binding to function.json, such as this
{
"name": "product",
"type": "sql",
"direction": "in",
"commandText": "select * from Products where Cost = @Cost",
"commandType": "Text",
"parameters": "@Cost = 10",
"connectionStringSetting": "SqlConnectionString"
}
- Run
func start - Trigger function
- Get this error
System.Private.CoreLib: Exception while executing function: Functions.HttpTrigger1. Microsoft.Data.SqlClient: Strings.PlatformNotSupported_DataSqlClient.
The root of the issue seems to be because there isn't a deps.json set up with the SqlClient runtime dependencies, so it errors out. This issue seems very similar : https://github.com/Azure/azure-functions-host/issues/5950
"Fix"/Workaround
I can fix this though by following these steps :
- Add package reference to
Microsoft.NET.Sdk.Functionsto extensions.csproj - Run
func extensions sync
This now generates the function.deps.json that we need. But adding this package breaks something else with the output, so now both that file and extensions.json are in the wrong place. They are both now being put under bin/bin (vs just bin like happened originally)
If I try to run func start at this point I get this error :
[2022-04-08T00:31:36.940Z] The 'HttpTrigger1' function is in error: The binding type(s) 'sql' are not registered. Please ensure the type is correct and the binding extension is installed.
Solution to this - copy these two files from bin/bin to bin. Once I do that and run func start again then everything seems happy.
But copying the files like this seems wrong, is there something I'm doing wrong here with how this is set up?
@brettsam Here's the issue I was talking to you about