Xariez
Xariez

Reputation: 789

Function app in Azure could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions'

Heyya,

We recently went through with upgrading all our projects from .NET Core 3.0 to 3.1, as well as most of the associated NuGet packages. The projects themselves are hosted as services and function-apps on portal.azure.com, and is transferred via a Bitbucket repository (pushed up from development, pulled down automagically by Azure).

This worked great for two out of three services, but the last one have proved to be difficult. The service itself is working fine, and it's (seemingly) doing what it should when testing it via localhost, but the associated Function-app is throwing "System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0>'. The system cannot find the file specified." at us.

After some investigating, it would seem there was no Microsoft.Extensions.Logging.Abstractions package installed at all according to our NuGet Manager, but it was still being used by ILogger in the code (explanations for this one are very welcome). Nevertheless, we forced a downgrade to Microsoft.Extensions.Logging.Abstractions version 3.1.10, tested the application via localhost before deploying it, and this time we got the exact same error message, thrown in Program.cs. Guessing this wouldn't make things better even if we tried pushing it up.

The target version of the function-app is ~3 (only ~3 and ~1 is available, not ~2), and it has worked prior to this. The AzureFunctionVersion (available in the project's configuration files) is v3. Re-creating the function-app on the Portal does not seem to have made any difference.

Upvotes: 0

Views: 2924

Answers (1)

Harshita Singh
Harshita Singh

Reputation: 4870

This usually happens when a Nuget package version is used by different nuget packages internally and is incompatible for at least one of them.

It means, there is a Nuget package in your project which requires Microsoft.Extensions.Logging.Abstractions version 5.0.0.0, but Azure Function latest version as of now installs version 2.1.1.

So, the solution is to upgrade Microsoft.Extensions.Logging.Abstractions version to 5.0.0.0 as SDK supports > 2.1.1:

enter image description here

enter image description here

OR

downgrade the dependent nuget package so that it uses 2.1.1 (or whichever version is installed in your project)

Upvotes: 1

Related Questions