azure-function-dependency-injection icon indicating copy to clipboard operation
azure-function-dependency-injection copied to clipboard

Dependency Injection built in to Azure Functions

Open justinkneff opened this issue 6 years ago • 2 comments

Microsoft released Dependency Injection functionality recently which is built on top of the ASP.NET Core Dependency Injection Features. What advantages and disadvantages does providing this solution using Attributes provide their functionality does not?

Is one or the other better performing? Is this faster cold boot? Is there functionality missing/provided by the other? What does compatibility look like with different IoC Containers, or package dependencies?

http://aka.ms/functions-di-docs

justinkneff avatar May 08 '19 00:05 justinkneff

One thing I've noticed is that this package has an [Inject] attribute which let's you inject the dependency directly into the parameter of the function.

The official DI implementation you have to inject it into a constructor which means that you can't have a static class/function.

Unless I'm missing something, but from that link there wasn't any usage examples so I'm going by: https://github.com/Azure/azure-functions-dotnet-extensions/tree/master/src/samples/DependencyInjection

juliusl avatar May 08 '19 01:05 juliusl

I just blogged about how to do setup and consume with the new bits and pieces https://blog.rasmustc.com/azure-functions-dependency-injection/

rasmuschristensen avatar May 08 '19 08:05 rasmuschristensen