Hi everyone,
I am currently trying to deploy a SQL Server module to store data on a device running Azure IoT Edge with Linux container following the official tutorial (https://learn.microsoft.com/en-us/azure/iot-edge/tutorial-store-data-sql-server?view=iotedge-2020-11).
Unfortunately there seem to be some problems regarding the SQL-connection:
1) The "sql"-module is up and running, but it says it is "disconnected":
2) It was possible to create the SQL-db and the table as described in the tutorial, but when I check the data in the table it is empty:
So sqlFunction does not seem to be able to connect to the SQL-db.
3) When checking the "sqlFunction"'s Troubleshoot"-option in the Azure portal it says:
[41m [30mfail [39m [22m [49m: Function.sqlFunction[3]
Executed 'sqlFunction' (Failed, Id=e83784d6-72e3-4312-a4b8-fce273256f20, Duration=158ms)
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: sqlFunction
---> System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform.
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Functions.Samples.sqlFunction.FilterMessageAndSendMessage(Message messageReceived, IAsyncCollector`1 output, ILogger logger) in /app/sqlFunction.cs:line 36
at Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\VoidTaskMethodInvoker.cs:line 20
at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 52
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 572
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 518
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 296
--- End of inner exception stack trace ---
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 343
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 105
Until now, I already tried to fix the problem by doing the following:
- Added package reference ("<PackageReference Include="System.Data.SqlClient" Version="4.5.1"/>") in sqlFunction.csproj
- Added "System.Data.SqlClient" Version="4.5.1" via Nuget Package Manager in Visual Studio Code
- Changed the "sql"-module's image URI in deployment.template.json from "microsoft/mssql-server-linux:2017-latest" to "mcr.microsoft.com/mssql/server:2019-CU14-ubuntu-20.04"
- Added the ports needed to the UFW firewall on my Linux IoT Edge device. Also tried disabling the firewall completely.
So far nothing helped and I am running out of ideas. Could you please help me?
Best regards