JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 50 forks source link

Moved DI IServiceCollection to one from WebJobsStartup #97

Closed alexeymarkov closed 4 years ago

alexeymarkov commented 5 years ago

…dencies properly.

For instance, now IDisposable scoped dependencies such as DbContext are released properly.

alexeymarkov commented 5 years ago

Sure it should be added to all templates.

alexeymarkov commented 5 years ago

Instead of using own IServiceCollection and build it into IServiceProvider more clever solutions would be to use IServiceCollection directly from FunctionStatrtup and inject IServiceProvider into a function class. This IServiceProvider instance is already scoped and would allow injection of ILogger, IConfiguration and everything else prepared for the function environment.

I will try to figure out how to implement it.

alexeymarkov commented 5 years ago

Good news: I almost finished the implementation but need a few hours to polish it.

alexeymarkov commented 5 years ago

I did not check for other triggers although I adjusted them too. Now IServiceCollection/IServiceProvider from WebJobsStartup are used.

JamesRandall commented 4 years ago

Many thanks for this everyone - super appreciated.

Its now in the v4 beta on master.