ASP.NET Core 3's new Host class resolves hosted services much earlier in the pipeline. This forced the .AddSimpleInjector extension method to add an IHostedService that ensured that the IServiceProvider was assigned to Simple Injector before such resolve takes place. This ensured that that hosted service can be injected with cross-wired dependencies.
Unfortunately, Azure Functions do not support hosted services and will throw an exception when any IHostedService is registered.
This means the addition of this hosted service by .AddSimpleInjector must be made conditional, such that Simple Injector's service collection integration can be used more easily with Azure functions.
Proposal:
services.AddSimpleInjector(this.container, options =>
{
options.EnableHostedServiceResolution = false; // Not supported by Azure Functions.
...
});
ASP.NET Core 3's new Host class resolves hosted services much earlier in the pipeline. This forced the
.AddSimpleInjector
extension method to add anIHostedService
that ensured that theIServiceProvider
was assigned to Simple Injector before such resolve takes place. This ensured that that hosted service can be injected with cross-wired dependencies.Unfortunately, Azure Functions do not support hosted services and will throw an exception when any
IHostedService
is registered.This means the addition of this hosted service by
.AddSimpleInjector
must be made conditional, such that Simple Injector's service collection integration can be used more easily with Azure functions.Proposal: