jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
327 stars 90 forks source link

Azure Function returns same instance for scoped service #74

Open jwyoung9 opened 5 years ago

jwyoung9 commented 5 years ago

I'm trying to use the new dependency injection features with Azure Functions where each invocation of the function should run within a dedicated scope. If I configure a scoped service, the instance injected into the function class is fine and changes each time the function is executed. However, the version injected into the request handler is always the same instance (singleton) and does not appear to be honoring the scope.

A sample project to repro the issue is attached: function_mediatr_test.zip

jbogard commented 5 years ago

Which version? The latest configures everything as Transient

jwyoung9 commented 5 years ago
<PackageReference Include="MediatR" Version="7.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.27" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
jbogard commented 5 years ago

Related? https://github.com/Azure/azure-functions-host/issues/3399

jwyoung9 commented 5 years ago

Ah - looks like it!

jtemperv commented 5 years ago

Hitting the same wall at the moment with the Azure Functions hots.

jwisener commented 5 years ago

Hitting the same issue.