0

I created a Timer Azure Function that called an API and wrote that json response to Azure SQL DB.

I wanted to continue my project, so I created an Azure Functions App in VS2017. I moved my code over and changed the #r script reference to the precompiled reference for the sqlclient.

From: (script calls)

r System.Configuration

r System.Data"

TO: (pre-compiled calls)

using System.Configuration;

using System.Data.SqlClient;

using System.Threading.Tasks;

Now I'm receiving a missing assembly reference for "System.Data.SqlClient" and I'm not sure how to add it to my Azure Functions App project in VS.

huysmania
  • 1,054
  • 5
  • 11

1 Answers1

1

Please go to your csproj to check which framework you are targeting. Based on your error, I guess it looks like this:

<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>

Which means you are on .NET Standard / Functions V2.

Either change it to .NET Framework / Functions V1:

<TargetFramework>net461</TargetFramework>

or reference the .NET Standard version of System.Data.SqlClient:

<PackageReference Include="System.Data.SqlClient" Version="4.4.3" />

V1 is the production version for now, and it's the one used for C# script, so I suggest you stick to it.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107