Azure-webjobs-sdk: 3.0.0-beta4 package: Microsoft.Extensions.Configuration.Abstraction version change caused by referenced EF Core throws error

Created on 23 Mar 2018  路  5Comments  路  Source: Azure/azure-webjobs-sdk

Summary: When EF Core is referenced in a project where Azure Durable Functions are used - brings Azure Webjobs 3.0.0-beta4 into picture - then Microsoft.Extensions.Configuration.Abstractions version is changing and as a consequence error will be thrown because the new - higher - version of Microsoft.Extensions.Configuration.Abstractions cannot be loaded.

Repro steps

Steps to reproduce

  • create a solution having two projects:

    • Azure Durable Function project (netstandard2.0)

    • DbContext project

    • upgrade the Function project to

    • latest durable task Microsoft.Azure.WebJobs.Extensions.DurableTask Version="1.2.0-beta3"

    • latest SDK Functions Microsoft.NET.Sdk.Functions Version="1.0.10"

    • apply the workaround here to be able to debug the project

    • put together some code which reads local.settings.json (example in the linked github repo)

    • worth to check the referenced nuget packages



      • you will see that Microsoft.Extensions.Configuration.Abstraction 2.0.0 is referenced


        2018-03-22_22-41-29_before_efcore



  • if you start the project in debug mode and you call the http://localhost:7071/api/test/get url (based on the example I provided) then the whole stuff works fine.
  • create another project in the same solution where you'll have a DbContext because you would like to communicate with your database, you would like to use EntityFramework Core.

    • worth to check the referenced packages of this project



      • you will see that the Microsoft.EntityFrameworkCore.Relational references the Microsoft.Extensions.Configuration.Abstractions version 2.0.1


        2018-03-22_23-00-17_ef_core_project



  • add the DbContext project as referenced project to FunctionApp1

    • the result is the next



      • you can add it :)


      • the fact you added this project as referenced project changes the original Microsoft.Extensions.Configuration.Abstractions version from 2.0.0 to 2.0.1


        2018-03-22_23-03-42_after_reference



  • run the project again in debug mode and call the same url as above

    • you will get the error message below

  • worth to check the content of {$ProjDir}/bin/Debug/netstandard2.0/bin directory

    • the dll is there and the version is fine, at least dotPeak says this

      2018-03-22_23-08-40_bindir

Expected behavior

Azure function is able to communicate databases via EntityFramework Core.

Actual behavior

Listening on http://localhost:7071/
Hit CTRL-C to exit...

Http Functions:

        Function1_HttpStart: http://localhost:7071/api/test/get

[3/22/2018 10:04:56 PM] Job host started
[3/22/2018 10:05:06 PM] Function started (Id=dfebf871-4835-45a7-a8c9-f3a07342a9cd)
[3/22/2018 10:05:06 PM] Executing 'Function1_HttpStart' (Reason='This function was programmatically called via the host APIs.', Id=dfebf871-4835-45a7-a8c9-f3a07342a9cd)
[3/22/2018 10:05:06 PM] A ScriptHost error has occurred
[3/22/2018 10:05:06 PM] Exception while executing function: Function1_HttpStart. FunctionApp1: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, 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.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/22/2018 10:05:06 PM] Exception while executing function: Function1_HttpStart
[3/22/2018 10:05:06 PM] Exception while executing function: Function1_HttpStart. FunctionApp1: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, 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.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/22/2018 10:05:07 PM] Function completed (Failure, Id=dfebf871-4835-45a7-a8c9-f3a07342a9cd, Duration=591ms)
[3/22/2018 10:05:07 PM]
[3/22/2018 10:05:07 PM] Executed 'Function1_HttpStart' (Failed, Id=dfebf871-4835-45a7-a8c9-f3a07342a9cd)
[3/22/2018 10:05:07 PM] System.Private.CoreLib: Exception while executing function: Function1_HttpStart. FunctionApp1: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, 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.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/22/2018 10:05:07 PM]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is 'dfebf871-4835-45a7-a8c9-f3a07342a9cd'
[3/22/2018 10:05:07 PM] System.Private.CoreLib: Exception while executing function: Function1_HttpStart. FunctionApp1: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, 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.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Known workarounds

I'm not aware of.

Related information

I tried so far:

  • @cgillum suggested to add Microsoft.Extensions.Configuration.Abstractions Version="2.0.1" as separate nuget package to Function1 project, but it dod not help.
  • Package version

    • see the examples above

  • Links to source

    • https://github.com/SayusiAndo/AzureDurableFunctionPackageConflict

I originally reported this at Azure Functions Durable Extensions project, but it turned out it is related rather to webjobs than durable functions.

Most helpful comment

When will this issue be resolved? Can't really have restrictions on upgrading EFCore because of this. It's the second issue within Azure "things", I have a similar issue within Azure Functions, there is another issue they don't seem to resolve, see: https://github.com/Azure/azure-functions-vs-build-sdk/issues/107
Would really appreciate an overview of what packages can be used with what, I know there are a lot of combinations but if some have restrictions then at least, your team internally and us, can know what the 'latest possible version' is.
I can imagine forgetting about this, upgrading EFCore or something else and come within the same problem again with other packages, this kind of creates a 'fear up upgrading' which should be avoided at all times.

All 5 comments

Ultimately this looks like it's the result of https://github.com/Azure/azure-functions-host/issues/992.

@fabiocav -- should adding a direct nuget reference have helped here?

We should be able to move all nugets forward which will help temporarily, but if any dependency moves forward again this will happen again.

Workaround for my case is downgrading EF Core packages to 2.0.1 which references Microsoft.Extensions.Configuration.Abstractions - 2.0.0. It works fine. As temporary solution it is fine for a while.

I was seeing the same issues with "Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0"

For me this occurred when using the
"Microsoft.Extensions.Configuration.Binder v2.0.1" and "Microsoft.Extensions.Configuration.EnvironmentVariables v2.0.1"

I could resolve it by downgrading both to v2.0.0 like @SayusiAndo described. Thanks for now!

Also have this same issue trying to use 3.0.0-beta5, with Microsoft.Extensions.DependencyInjection v2.0.0 results in

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.2.0, 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.Extensions.Configuration.Abstractions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Tried referencing the package directly, same result.

When will this issue be resolved? Can't really have restrictions on upgrading EFCore because of this. It's the second issue within Azure "things", I have a similar issue within Azure Functions, there is another issue they don't seem to resolve, see: https://github.com/Azure/azure-functions-vs-build-sdk/issues/107
Would really appreciate an overview of what packages can be used with what, I know there are a lot of combinations but if some have restrictions then at least, your team internally and us, can know what the 'latest possible version' is.
I can imagine forgetting about this, upgrading EFCore or something else and come within the same problem again with other packages, this kind of creates a 'fear up upgrading' which should be avoided at all times.

Was this page helpful?
0 / 5 - 0 ratings