2

Currently I am using DI in azure functions the standard way


public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
       /*Register dependencies*/
    }
}

(Microsoft.Azure.Functions.Extensions.DependencyInjection.FunctionsStartup)


Is it possible to switch to https://github.com/dadhi/DryIoc container while still being able to use DI to resolve dependencies through constructor of azure functions? If so, how?
Ecstasy
  • 1,866
  • 1
  • 9
  • 17
  • Ok. Very interested to hear the answer as well. I did not checked it lately but the AF host was using the code from the DryIoc as impl. detail... – dadhi May 04 '22 at 15:55
  • Hey @Stepan U! had it solved your problem else you can share more details so I can troubleshoot? – PunitSharma May 16 '22 at 12:49

2 Answers2

0

So the answer to my question is that it is possible. But it requires implementing custom IJobActivatorEx and IJobActivator. And then replace it in IServiceCollection.

hostBuilder.Services.Replace( ServiceDescriptor.Singleton(typeof(IJobActivator), typeof(ScopedJobActivator)));
hostBuilder.Services.Replace( ServiceDescriptor.Singleton(typeof(IJobActivatorEx), typeof(ScopedJobActivator)));

I found this implementation in Autofac container extension https://github.com/junalmeida/autofac-azurefunctions in class ConfigurationExtensions

Sadly, I don't yet have working implementation for DryIoc.

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
0

Ok, here is the implementation in DryIoc https://github.com/dadhi/DryIoc/blob/master/src/DryIoc.AzureFunctions/DryIocAzureFunctions.cs

There is a preview package as well: https://www.nuget.org/packages/DryIoc.AzureFunctions/1.0.0-preview-01

dadhi
  • 4,807
  • 19
  • 25