How to be able to start an Azure Function which requires the nuget package EntityFrameworkcore.SqlServer ?

Thomas Fabre 20 Reputation points
2023-11-17T16:34:59.61+00:00

I need to access my database in a Function App (named FAOnnx), therefore I want to use the nuget package Microsoft.EntityFrameworkCore.SqlServer but when i'm adding this package and try to launch my Azure function I got the following error : The 'FAOnnx' function is in error: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Step to reproduce :

  1. Create an Azure Function Project
  2. Create an Azure Function named "FAOnnx"
    1. Do a Hello World program
    2. start the program
    3. Everything's ok
    4. Add the package Microsoft.EntityFrameworkCore.SqlServer to the project
    5. Start the project again and the Hello World won't work.
    Adding the 'Microsoft.Extensions.Logging.Abstractions' package doesn't change anything. Here is my entire console log :

    [2023-11-17T16:30:04.164Z] Found C:\Users[MyUser]\Documents\Code\Air\Predictions_2\FunctionAppOnnx\FunctionAppOnnx.csproj. Using for user secrets file configuration.

[2023-11-17T16:30:07.088Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.). [2023-11-17T16:30:07.151Z] The 'FAOnnx' function is in error: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. For detailed output, run func with --verbose flag.

Developer technologies | .NET | Entity Framework Core
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-11-20T16:37:34.8466667+00:00

    Thomas Fabre Thanks for sharing the additional information. It appears that you are referencing Microsoft.EntityFrameworkCore.SqlServer 7.0.3 which depends on Microsoft.Extensions.Logging.Abstractions >=7.0.3 and as per NuGet package doc, this version supports .Net 6. However, there is a limitation in in-process model of Functions runtime V4 (running .NET 6) which restrict the dependencies to 6.0.0 and hence you got the error. More details/discussion can be found here.

    So, if you are looking to target .NET 6, the recommendation is to move Isolated model (no such dependency restrictions) or use 6.0.0 version of Microsoft.EntityFrameworkCore NuGet package in your project.

    I hope this helps and let me know if any questions.


    If you found the answer to your question helpful, please take a moment to mark it as Yes for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.