Azure / azure-functions-dotnet-extensions

Azure Functions .NET extensions
MIT License
75 stars 42 forks source link

DependencyInjection stops working when we add User Secrets (Error: "Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve [injected service] while attempting to activate [function]) #59

Closed GCoding83 closed 3 years ago

GCoding83 commented 3 years ago

I know this issue was already discussed here: https://github.com/Azure/azure-functions-dotnet-extensions/issues/45, but the issue should not have been closed. The person in that thread mentioned that they solved their problem by simply installing Microsoft.Extensions.Configuration.UserSecrets, but I personally have that package installed. As soon as I installed it, my Dependency Injection stopped working.

I created a very basic Functions app to show the problem. The function only has three installed packages. The csproj file is:

image

The Startup.cs file:

image

And the very simple function:

image

When I run the application (locally) I get the following error message:

image

Obviously, the error disappears if I remove the User Secrets package, but I need to be able to use User Secrets... There has to be a solution?