Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Microsoft.Extensions.DependencyInjection v2.2.0 #26

Open
AlexPiksel opened this issue Dec 17, 2018 · 6 comments
Open

Comments

@AlexPiksel
Copy link

This may be a duplicate of #21, although that doesn't capture the impact.

We've just updated our project to .NET Core 2.2 / EF Core 2.2, which means the datalayer class library our Functions project references now has a dependency on Microsoft.Extensions.DependencyInjection >= 2.2.0

This causes the following error on startup:

[17/12/2018 14:51:49] A host error has occurred
[17/12/2018 14:51:49] Willezone.Azure.WebJobs.Extensions.DependencyInjection: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.WebJobs.IWebJobsBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider

This prevents the function from starting.

If I downgrade the data layer back to 2.1.x libraries, the error goes away. If I then add an explicit reference to Microsoft.Extensions.DependencyInjection v2.2.0 to the functions project, it comes back, so it looks like this is the culprit.

For reference, both the Function project and the class library it's referencing are netstandard2.0. My local functions runtime is 2.0.12210.0, while Azure is running 2.0.12246.0 - same issue seen in both.

@DarranShepherd
Copy link

Having had a bit of a dig through, I don't think this can be done until Microsoft.Azure.WebJobs.Host is also upgraded to 2.2

We ran into the issue, but not after an upgrade - we were creating an entirely new project and had, as such, added a dependency on Microsoft.Extensions.Options version 2.2.0 to add IOptions<T> to DI.

We observed the error reported above, but also

A host error has occurred
[20/12/2018 16:45:02] Willezone.Azure.WebJobs.Extensions.DependencyInjection: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.WebJobs.IWebJobsBuilder.get_Services()'.

Ensuring that all ASP.NET Core references were pegged at 2.1.1 has resolved it for us for now.

@StefH
Copy link

StefH commented Dec 20, 2018

@BorisWilhelms

Maybe an out-of-the-box question : why not create a source-code only NuGet package ? In that way you don't need to upgrade the NuGet everytime Microsoft releases a new version from a library,

@adrianm64
Copy link

adrianm64 commented Dec 23, 2018

@StefH,

Maybe an out-of-the-box question : why not create a source-code only NuGet package ? In that way you don't need to upgrade the NuGet everytime Microsoft releases a new version from a library,

Yes, that is probably the right approach since AF is so picky with common dependencies. I use that for our internal utilities in v1. Unfortunately it doesn't work in v2 because the runtime only picks up extensions in external dependencies and fix is not a priority Azure/Azure-Functions#972

@SeriousM
Copy link

It sounds like it's a priority!

Azure/Azure-Functions#972 (comment)

@StefH
Copy link

StefH commented Dec 28, 2018

@adrianm64
Another option would be to more active manage this project + nuget. And keep the same version scheme as from Microsoft.

So make multiple versions from Willezone.Azure.WebJobs.Extensions.DependencyInjection which align with Microsoft.Azure.WebJobs:

  • 2.1.0
  • 2.2.0
  • 3.0.0
  • 3.0.1
  • 3.0.3

@kensykora
Copy link

kensykora commented Aug 21, 2019

For those running into this issue, I found I was able to get past it by updating my Azure Functions Runtime that ships with VS for Mac to latest as of this posting

Azure Functions Core Tools (2.7.1575 Commit hash: b7750e771a4e56352c767dfa16413ec9c79b72ba)
Function Runtime Version: 2.0.12625.0

This SO post pointed me in the right direction: https://stackoverflow.com/questions/55377996/net-core-2-2-azure-function-v2-dependency-injection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants