Dependency Injection in Azure Functions results "Unable to resolve service for type..." error
See original GitHub issueHi,
I had a azure function running when it suddenly didn’t and returned the error:
Unable to resolve service for type...
Which is surprising for I have other azure functions with DI running without issue.
All functions work fine in local system.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Dependency Injection unable to resolve service for type in . ...
In the solution that defines our function app (.NET Core 2.2) I've made sure the right NuGet packages are installed: Microsoft.Azure.Functions.
Read more >Dependency Injection issue: Unable to resolve service for ...
I just deployed the function to Azure, and it is working. It's only locally I'm getting this error.
Read more >Implement Dependency Injection in Azure Functions for ...
Solution was to use the interface in the constructor, not the instance class. Apparently, I am not alone: https://stackoverflow.com/questions/ ...
Read more >Azure Function DI Failure Unable to resolve service for ...
DependencyInjection : Unable to resolve service for type 'Microsoft.Azure.WebJobs.Script.IEnvironment' while attempting to activate 'Microsoft.
Read more >Use dependency injection in .NET Azure Functions
Learn how to use dependency injection for registering and using services in .NET functions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ThapaMahesh – can you check that this host file is being deployed to Azure? It doesn’t appear that it is, and you’re running into a bug that was introduced recently when a host.json file is missing. It causes us to incorrectly inject the usage of extensions bundles, which means we’re not calling your startup class.
We see this in your logs, which means that there was no host.json, so we generated one for you:
If you make sure to deploy the default host.json from above, it should get back to working again.
//cc @soninaren
@siji147 the host file contains
{ "version": "2.0" }