Azure Function - Error while import Microsoft.Data.SqlClient dll in Azure function csx file

Akshay Kumar 0 Reputation points
2023-02-21T23:11:38.93+00:00

I have one requirement to use the system.data.sqlclient library in the Azure Function V4 on the portal.

When I tried it this way but it return the error.

Could you please help me how to use the library in the Azure Function on the portal.

This is a run.csx file

using System.Data.SqlClient;

using System;

public static void Run(TimerInfo myTimer, ILogger log)
{
    var conn = new SqlConnection("MyConnectionString");
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}

I am getting this error while executing the function on the portal.

run.csx(7,20): error CS1069: The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly

I have develop function App on the VS Code and use the library it's working fine as well as when I downgrade my function App from V4 to V3. It's working fine with same code but when I am trying to upgrade the function App with V4, it returns the error.

see here : https://github.com/dotnet/SqlClient/issues/1512

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,001 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.