I am trying to reference a class library (Target Framework .Net Framework 4.6.1) from a Azure Function App project (created using Function App v2 template) with Target Framework as .Net Standard 2.0. The .net 4.6.1 class library has a nuget package installed for System.Data.SqlClient v4.4.3 to support any SQL operations. I then call the SQL class library operation from Function App project. Things compile properly but at run time I get following error:
Exception while executing function: DownloadEncryptedOrderFiles. SQLLib: Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
As per suggestions given on some online forums, I also downgraded SQLClient nuget package to 4.4.0, but it still does not work. Seems like the SQLClient dll does not get copied to the bin directory of functions and hence it fails at runtime. I am wondering if it is OK to reference a .net 4.6.1 project from Azure Functions? If yes then what am I doing wrong.
Here are the details of the runtime environment:
- VS - 2017, v15.6.1
Installed Products:
- Azure App Service Tools v3.0.0
- Azure Functions and Web Jobs Tools 15.0.40215.0
- Nuget Package Manager 4.6.0