I already opened an issue in
Azure/azure-functions-host and I have a repo with the repro steps, but I'm posting this here in case there is something inherently wrong with what I'm doing, or someone has already stumbled open this issue.
My goal: I want to run in an azure function some code that lives in a class library in an existing visual studio solution.
This code happens to use entity framework core in order to read and write to a SQL Server database.
While trying to isolate the issues I was facing, I ended up with the following scenario:
In Visual Studio: File > New > Project > Azure Functions
Azure Functions v2 Preview (.NET Core)
Select Access rights
Install using nuget
Add an invocation to anything from the
In my case I added the following line:
Ensure the azure storage emulator is running
Run the function from visual studio (
Hit the url printed in the console
Expected behavior: along with the default behavior of the example
Http trigger function I expect to see the following line printed with each invocation:
Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=22.214.171.124, Culture=neutral, PublicKeyToken=adb9793829ddae60
Actual behavior: the app throws an exception at runtime and outputs the following
[11-Apr-18 6:33:59 AM] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=6faabfd8-eb96-4d71-906c-940028a7978a)
[11-Apr-18 6:33:59 AM] Executed 'Function1' (Failed, Id=6faabfd8-eb96-4d71-906c-940028a7978a)
[11-Apr-18 6:33:59 AM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=126.96.36.199, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=188.8.131.52, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Current conjecture: while researching this issue I found something that might be related:
The Azure functions runtime already has a set of packages available, one of those being
Newtonsoft.Json in a specific version. In the case a newer version of
Newtonsoft.Json is referenced from the project a similar behavior is observed.
Microsoft.EntityFrameworkCore roll back to version 2.0.1. Don't know if it is a known EFCore issue, but rolling back to 2.0.1 helped med with the exact same issue.