Azure-functions-core-tools: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0

Created on 19 Nov 2020  Â·  29Comments  Â·  Source: Azure/azure-functions-core-tools

I have an Azure Function that is deployed and has been working for a while. I just made some more changes and upgraded some nuget packages and suddenly while debugging locally I started getting some errors while running the function. The error I get is:
[2020-11-19T20:37:35.407Z] A host error has occurred during startup operation '24d5b302-c1ac-4501-ae05-88204ffe8ba3'.
[2020-11-19T20:37:35.408Z] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

I tried to rollback my changes and after rolling back many changes I made I cannot get the function app to run in my local machine. I have not tried to deploy as I need the app in Azure to work for now.

Below is my function app and the common project setup. I have spent two days trying to get this back to a running state and have no luck. I have a feeling that something got updated and some reflection operation is not happy with something, just not sure what.

I have tried adding the Microsoft.Extensions.Logging.Abstractions package to both my function app and common library and have had no luck with this.

Any help would be greatly appreciated as I really ran into a dead end on this.

Regards
Fabian

This is my tooling information:
Azure Functions Core Tools
Core Tools Version: 3.0.2996 Commit hash: c54cdc36323e9543ba11fb61dd107616e9022bba
Function Runtime Version: 3.0.14916.0

image

image

In case it helps, this is the verbose version of the console output:

[2020-11-19T21:50:25.327Z] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'f0e7565a-5f40-4e51-a172-b1f53f9e7ece'
[2020-11-19T21:50:25.358Z] Reading host configuration file 'C:Usersfv2sourcereposDataLakeFunctionsDataLakeSizebinDebugnetcoreapp3.1host.json'
[2020-11-19T21:50:25.361Z] Host configuration file read:
[2020-11-19T21:50:25.362Z] {
[2020-11-19T21:50:25.362Z] "version": "2.0",
[2020-11-19T21:50:25.362Z] "logging": {
[2020-11-19T21:50:25.363Z] "applicationInsights": {
[2020-11-19T21:50:25.363Z] "samplingExcludedTypes": "Request",
[2020-11-19T21:50:25.364Z] "samplingSettings": {
[2020-11-19T21:50:25.364Z] "isEnabled": true
[2020-11-19T21:50:25.364Z] }
[2020-11-19T21:50:25.365Z] }
[2020-11-19T21:50:25.365Z] }
[2020-11-19T21:50:25.366Z] }
[2020-11-19T21:50:25.383Z] Loading functions metadata
[2020-11-19T21:50:25.385Z] Reading functions metadata
[2020-11-19T21:50:25.397Z] 5 functions found
[2020-11-19T21:50:25.408Z] 5 functions loaded
[2020-11-19T21:50:25.411Z] Loading extensions from C:Usersfv2sourcereposDataLakeFunctionsDataLakeSizebinDebugnetcoreapp3.1bin. BundleConfigured: False, PrecompiledFunctionApp: False, LegacyBundle: False
[2020-11-19T21:50:25.415Z] Loading startup extension 'DurableTask'
[2020-11-19T21:50:25.510Z] Loaded extension 'DurableTask' (2.0.0.0)
[2020-11-19T21:50:25.554Z] Reading host configuration file 'C:Usersfv2sourcereposDataLakeFunctionsDataLakeSizebinDebugnetcoreapp3.1host.json'
[2020-11-19T21:50:25.556Z] Host configuration file read:
[2020-11-19T21:50:25.557Z] {
[2020-11-19T21:50:25.557Z] "version": "2.0",
[2020-11-19T21:50:25.557Z] "logging": {
[2020-11-19T21:50:25.558Z] "applicationInsights": {
[2020-11-19T21:50:25.558Z] "samplingExcludedTypes": "Request",
[2020-11-19T21:50:25.559Z] "samplingSettings": {
[2020-11-19T21:50:25.559Z] "isEnabled": true
[2020-11-19T21:50:25.559Z] }
[2020-11-19T21:50:25.560Z] }
[2020-11-19T21:50:25.560Z] }
[2020-11-19T21:50:25.561Z] }
[2020-11-19T21:50:26.080Z] Initializing Warmup Extension.
[2020-11-19T21:50:26.396Z] Durable extension configuration loaded: {"httpSettings":{"defaultAsyncRequestSleepTimeMilliseconds":30000},"hubName":"TestHubName","storageProvider":{"connectionStringName":null,"controlQueueBatchSize":32,"partitionCount":4,"controlQueueBufferThreshold":256,"controlQueueVisibilityTimeout":"00:05:00","workItemQueueVisibilityTimeout":"00:05:00","trackingStoreConnectionStringName":null,"trackingStoreNamePrefix":null,"fetchLargeMessagesAutomatically":true,"maxQueuePollingInterval":"00:00:30","useLegacyPartitionManagement":false},"tracing":{"traceInputsAndOutputs":false,"allowVerboseLinuxTelemetry":false,"traceReplayEvents":false},"notifications":{"eventGrid":null},"maxConcurrentActivityFunctions":80,"maxConcurrentOrchestratorFunctions":80,"notificationUrl":"http://localhost:7071/runtime/webhooks/durabletask","localRpcEndpointEnabled":null,"extendedSessionsEnabled":false,"extendedSessionIdleTimeoutInSeconds":30,"maxOrchestrationActions":100000,"overridableExistingInstanceStates":"NonRunningStates","entityMessageReorderWindowInMinutes":30,"useGracefulShutdown":false,"rollbackEntityOperationsOnExceptions":true,"useAppLease":true,"appLeaseOptions":{"renewInterval":"00:00:25","acquireInterval":"00:05:00","leaseInterval":"00:01:00"}}. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.3.1.
[2020-11-19T21:50:26.446Z] Initializing Host. OperationId: 'f0e7565a-5f40-4e51-a172-b1f53f9e7ece'.
[2020-11-19T21:50:26.454Z] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=f0e7565a-5f40-4e51-a172-b1f53f9e7ece
[2020-11-19T21:50:26.473Z] LoggerFilterOptions
[2020-11-19T21:50:26.473Z] {
[2020-11-19T21:50:26.475Z] "MinLevel": "None",
[2020-11-19T21:50:26.475Z] "Rules": [
[2020-11-19T21:50:26.477Z] {
[2020-11-19T21:50:26.477Z] "ProviderName": null,
[2020-11-19T21:50:26.479Z] "CategoryName": null,
[2020-11-19T21:50:26.479Z] "LogLevel": null,
[2020-11-19T21:50:26.480Z] "Filter": "b__0"
[2020-11-19T21:50:26.481Z] },
[2020-11-19T21:50:26.489Z] {
[2020-11-19T21:50:26.490Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2020-11-19T21:50:26.490Z] "CategoryName": null,
[2020-11-19T21:50:26.491Z] "LogLevel": "None",
[2020-11-19T21:50:26.492Z] "Filter": null
[2020-11-19T21:50:26.494Z] },
[2020-11-19T21:50:26.500Z] {
[2020-11-19T21:50:26.501Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2020-11-19T21:50:26.504Z] "CategoryName": null,
[2020-11-19T21:50:26.510Z] "LogLevel": null,
[2020-11-19T21:50:26.513Z] "Filter": "b__0"
[2020-11-19T21:50:26.521Z] },
[2020-11-19T21:50:26.532Z] {
[2020-11-19T21:50:26.536Z] "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
[2020-11-19T21:50:26.546Z] "CategoryName": null,
[2020-11-19T21:50:26.547Z] "LogLevel": null,
[2020-11-19T21:50:26.555Z] "Filter": "b__0"
[2020-11-19T21:50:26.557Z] }
[2020-11-19T21:50:26.565Z] ]
[2020-11-19T21:50:26.565Z] }
[2020-11-19T21:50:26.573Z] LoggerFilterOptions
[2020-11-19T21:50:26.575Z] {
[2020-11-19T21:50:26.583Z] "MinLevel": "None",
[2020-11-19T21:50:26.594Z] "Rules": [
[2020-11-19T21:50:26.595Z] {
[2020-11-19T21:50:26.602Z] "ProviderName": null,
[2020-11-19T21:50:26.605Z] "CategoryName": null,
[2020-11-19T21:50:26.611Z] "LogLevel": null,
[2020-11-19T21:50:26.614Z] "Filter": "b__0"
[2020-11-19T21:50:26.620Z] },
[2020-11-19T21:50:26.624Z] {
[2020-11-19T21:50:26.633Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2020-11-19T21:50:26.635Z] "CategoryName": null,
[2020-11-19T21:50:26.636Z] "LogLevel": "None",
[2020-11-19T21:50:26.644Z] "Filter": null
[2020-11-19T21:50:26.651Z] },
[2020-11-19T21:50:26.654Z] {
[2020-11-19T21:50:26.654Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2020-11-19T21:50:26.664Z] "CategoryName": null,
[2020-11-19T21:50:26.673Z] "LogLevel": null,
[2020-11-19T21:50:26.674Z] "Filter": "b__0"
[2020-11-19T21:50:26.681Z] },
[2020-11-19T21:50:26.684Z] {
[2020-11-19T21:50:26.684Z] "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
[2020-11-19T21:50:26.694Z] "CategoryName": null,
[2020-11-19T21:50:26.701Z] "LogLevel": null,
[2020-11-19T21:50:26.704Z] "Filter": "b__0"
[2020-11-19T21:50:26.712Z] }
[2020-11-19T21:50:26.715Z] ]
[2020-11-19T21:50:26.721Z] }
[2020-11-19T21:50:26.726Z] FunctionResultAggregatorOptions
[2020-11-19T21:50:26.734Z] {
[2020-11-19T21:50:26.736Z] "BatchSize": 1000,
[2020-11-19T21:50:26.744Z] "FlushTimeout": "00:00:30",
[2020-11-19T21:50:26.746Z] "IsEnabled": true
[2020-11-19T21:50:26.753Z] }
[2020-11-19T21:50:26.755Z] SingletonOptions
[2020-11-19T21:50:26.763Z] {
[2020-11-19T21:50:26.766Z] "LockPeriod": "00:00:15",
[2020-11-19T21:50:26.773Z] "ListenerLockPeriod": "00:00:15",
[2020-11-19T21:50:26.776Z] "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[2020-11-19T21:50:26.784Z] "LockAcquisitionPollingInterval": "00:00:05",
[2020-11-19T21:50:26.786Z] "ListenerLockRecoveryPollingInterval": "00:01:00"
[2020-11-19T21:50:26.793Z] }
[2020-11-19T21:50:26.797Z] HttpOptions
[2020-11-19T21:50:26.804Z] {
[2020-11-19T21:50:26.812Z] "DynamicThrottlesEnabled": false,
[2020-11-19T21:50:26.815Z] "MaxConcurrentRequests": -1,
[2020-11-19T21:50:26.816Z] "MaxOutstandingRequests": -1,
[2020-11-19T21:50:26.823Z] "RoutePrefix": "api"
[2020-11-19T21:50:26.825Z] }
[2020-11-19T21:50:26.828Z] Starting JobHost
[2020-11-19T21:50:26.833Z] Starting Host (HostId=valenciaf2l-1803538091, InstanceId=d3ef885e-b69a-4e3c-9b9a-6049a9d34328, Version=3.0.14916.0, ProcessId=21368, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[2020-11-19T21:50:26.869Z] Loading functions metadata
[2020-11-19T21:50:26.887Z] 5 functions loaded
[2020-11-19T21:50:27.031Z] Generating 0 job function(s)
[2020-11-19T21:50:27.066Z] A host error has occurred during startup operation 'f0e7565a-5f40-4e51-a172-b1f53f9e7ece'.
[2020-11-19T21:50:27.068Z] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
[2020-11-19T21:50:27.075Z] Stopping JobHost
Value cannot be null. (Parameter 'provider')
[2020-11-19T21:50:27.180Z] Initialization cancellation requested by runtime.
[2020-11-19T21:50:27.185Z] Stopping host...
[2020-11-19T21:50:27.186Z] Host shutdown completed.

P1

Most helpful comment

The only solution is to avoid using v5 packages. We'll have a .NET 5 worker available in preview soon that should unblock this.

All 29 comments

I'm in the same boat!

This might help, @omarko and @fvalencia12: https://github.com/Azure/Azure-Functions/issues/1525

Well, I don't know what exactly broke my function, it might have been a Visual Studio upgrade which installed .net core 5 or company patching, don't really know.

What I do know is that I downgraded all the 5.0.0 libraries such as Microsoft.EntityFrameworkCore.SqlServer from 5.0 to 3.1 and Microsoft.Extensions.Configuration.UserSecrets from 5.0 to 3.1. That Fixed the problem for me.

The 5.0 libraries are probably .net core 5.0 ready and are having a conflict with Azure Functions or Entity Framework. I have seen this happen when a new version of the .net framework comes out and it takes a few weeks for EF, Azure Functions and other components that sit on top of the framework to iron out their issues.

Oh well, I'll keep out of the 5.0 libraries for a while. This really wasted countless hours this week for me.

Yes, it cost me and my colleague many hours as well...

Problem is, that there might be transient dependencies on 5.x libs, which does not necessarily mean they won't work - but they might get stripped by the functions core tools.

Getting same error after updating packages:
A host error has occurred during startup operation '08e2f72c-200d-4b6f-bcc4-4904be42bab7'.
[2020-11-22T22:30:36.800Z] **.Functions: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Looks like the issue is that Microsoft.EntityFrameworkCore.SqlServer has a transitive dependency on newer versions of some packages such as Microsoft.Extensions.Logging.Abstractions that conflict with the ones running in the functions host. We'll take a look to see how we can address this. @fabiocav

I'm also affected by this. Also needed to upgrade to Microsoft.EntityFrameworkCore.SqlServer 5.0.0 which probably broke it.

as i commented in https://github.com/Azure/azure-functions-host/issues/6893#issuecomment-726386105

  • when you run azure functions, it starts before it loads your code.
  • only 1 version of a dll can be loaded at once.

Consequence: if you need a library that is a direct or indirect dependency of azure functions you can only use the version that is loaded. This is a case where azure functions is incorrectly reporting its hard dependencies.

eg: if you are using azure functions 3.0.7, then you must use a library binary compatible with logging.abstractions 2.1.0
When your code (eg if you have a asp.netcore dependencency) asks for something that is only found in Abstractions >=5.0 the runtime (correctly) responds "sorry, that function isn't there", because all it has is the 2.1.0 dll in memory.

image

Therefore the many tickets that will be raised that are like this can only be solved by upgrading azure functions to a newer version which has a dependency on the 5.x line of the abstractions.

In this particular case, if azure functions used Microsoft.Extensions.Logging.Abstractions 5.0, then it would be fine because that library appears to be backwards compatible so the reverse error doesn't occur (no runtime failure if you expect 2.1 and actually get 5.0).

If that is not true for all libraries in common between azure functions and the libraries your code uses, then you will be pinned in terms of your dependencies and azure functions versions.

Any resolution on this? We are getting the same error System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

"Function host is not running." when the function app URL is clicked.

The only solution is to avoid using v5 packages. We'll have a .NET 5 worker available in preview soon that should unblock this.

Resolved by downgrading to 3.1 packages.

@AartBluestoke just want to comment to add some clarity.

The following statement is inaccurate:

Consequence: if you need a library that is a direct or indirect dependency of azure functions you can only use the version that is loaded. This is a case where azure functions is incorrectly reporting its hard dependencies.

The only dependencies that are currently restricted are .NET and WebJobs. In those cases, we perform automatic unification within safe ranges. Any other dependency brought by your application is loaded in isolation, and if also used by the host, it is loaded side-by-side with the version the host uses.

Hope this helps.

Is there any update on this?
As long Functions do not support net5, we cannot reference any other project that is built for net5. It would be great to align Azure Functions in the future to a new version of .net.
In real life, a typical project that implements intellectual property is not implemented in the function project. If it would be, we would simply now downgrade the function project to 3.1

But a function project is usually just a wrapper around the real implementation. It is just a single project in the solution of many projects (i.e. 100 projects). Downgrading the function project to 3.1 would mean downgrading all dependencies to 3.1. This is mostly impossible from the organization point of view.

Thanks, @ashaherb. Any approx. release date?

This is a very nice change and much needed update. Kudos to the team for realizing this is an issue and addressing it!!!!!

Fabian Valencia
Information Technology
William Blair
The William Blair Building | 150 North Riverside Plaza, Chicago, Illinois 60606
Direct: +1-312-364-5132
[email protected]fvalencia@williamblair.com | williamblair.comhttp://www.williamblair.com/
Facebookhttps://www.facebook.com/WilliamBlairCo/ | LinkedInhttps://www.linkedin.com/company/166939 | YouTubehttps://www.youtube.com/channel/UC7CPnCaTlZcLxOF7WFwY0uw | Twitterhttps://twitter.com/WilliamBlair

From: Sebastian notifications@github.com
Sent: Thursday, January 14, 2021 3:06 AM
To: Azure/azure-functions-core-tools azure-functions-core-tools@noreply.github.com
Cc: Valencia, Fabian FValencia@williamblair.com; Mention mention@noreply.github.com
Subject: Re: [Azure/azure-functions-core-tools] Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0 (#2304)

@ddobrichttps://github.com/ddobric .NET 5 support for Functions is in preview now https://techcommunity.microsoft.com/t5/apps-on-azure/net-5-support-on-azure-functions/ba-p/1973055

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-functions-core-tools/issues/2304#issuecomment-760050031, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQZG2MYZJCBIOBEJR56WUK3SZ2XXBANCNFSM4T36F4UA.

Just to confirm about the .NET 5 worker. Here (https://github.com/Azure/azure-functions-dotnet-worker-preview) I can read:
"_One important difference with .NET 5 functions is that "rich bindings", such as Durable Functions or binding to SDK types like Cosmos DB client, are not supported. Use strings and C# objects (POCOs). For HTTP, use HttpRequestData and HttpResponseData objects._"

@anthonychu Does it mean we cannot use Durable Functions with that worker, right?

Thanks.

from this thread

We currently don’t have plans to bring Durable Functions to this worker for the .NET 5 timeframe. We plan to have the host updated to .NET 6 LTS, and Durable Functions should run fine on that. We will evaluate whether we will bring Durable Functions to this worker long term.

Thanks for the info @sebader ... sad to see that, as then .net 5 is not an option for me, and .NET 6 is still far. It also makes not possible to use the great new EF Core 5 in Functions v3 (that requires Durable functions)... shame.
Thanks again.

Hi @sebader, Hi All Is there any update on below issue Functions runtime error:
: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Azure Functions v3 (.Net Core)
Target Framework: .Net Core 3.1
Microsoft.EntityFrameorkCore.SqlServer::3.1.4

Note : This same function is running fine from my local but once deployed to portal then getting the Functione runtime error :-(

AZ Func RunTime Error

Resolved by downgrading to 3.1 packages.
Hi @TissonMathew
Could you please elaborate/ give more details about the resolution. Because in my case Microsoft.EntityFrameorkCore.SqlServer: is 3.1.4 ..
Thanks in advance
EFCORE SQLSERVER 3 x

@anthonychu Thanks for providing this workaround. As I am sure you understand the shortcomings discussed in this thread make .NET 5 somewhat unusable for a lot people, companies and projects. Azure Functions is such a key service for many.
When this workaround will be fully integrated into .NET 5? We need an approximate date to plan which way we go.
Can you please provide that?
Thanks!

@evangeloper also note that even with the worker for .NET 5, it won´t support Durable functions until .NET 6 (scheduled for November 2021), so double check you´re not using Durable functions. For me is not an option, so have to go with .net 3.1 :(

@luismanez for this particular project I won't be using durable functions. I want to take advantage of the new EF Core 5 features, but this is not an option as of now without the workaround.
I just wish to have a GA date, so I know whether to go with .NET Core 3.1 or .NET 5.

downgraded all the 5.0.0 libraries such as Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuitefrom 5.0 to 3.1.x. This resolved the issue for now .

Can you explain why the combination of my netcoreapp3.1 app with Microsoft.Extensions.Logging.Abstractions 5.0 running with the functions sdk 3.0.3233 does not seem to work? Microsoft.Extensions.Logging.Abstractions 5.0 claims to be compatible with downstream .NET Standard 2.0.

My explanation is that v3 functions sdk linker trims the Microsoft.Extensions.Logging.Abstractions 5.0 reference under the assumption that the host is already providing the required assembly.

With the .NET 5 host the app will not be running in the same scope as the host anymore so that the app is free to consume all of its own dependencies.

Encountered the same problem today. Had to find the 5.0 references in the depending projects of the function and downgrade them all to 3.X. Lost some cool new features with Entity Framework 5.0 on the way. Hoping the problem gets fixed Function-side.

Any update on this?

What solved my problem is running dotnet publish with the following argument (-p:IncludeNativeLibrariesForSelfExtract=true):
- task: DotNetCoreCLI@2 displayName: "dotnet publish $(solution)" inputs: command: "publish" publishWebProjects: true modifyOutputPath: false zipAfterPublish: false projects: "$(solution)" arguments: "--framework net5.0 --runtime win-x64 --output $(msbuildOutputRoot) -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"

Hope it helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frozenbubble picture frozenbubble  Â·  4Comments

SteveALee picture SteveALee  Â·  4Comments

sonic1981 picture sonic1981  Â·  4Comments

brandonh-msft picture brandonh-msft  Â·  4Comments

solvingj picture solvingj  Â·  5Comments