Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Azure Function returns same instance for scoped service #74

Open
jwyoung9 opened this issue May 11, 2019 · 6 comments
Open

Azure Function returns same instance for scoped service #74

jwyoung9 opened this issue May 11, 2019 · 6 comments

Comments

@jwyoung9
Copy link

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
Copy link
Owner

jbogard commented May 11, 2019

Which version? The latest configures everything as Transient

@jwyoung9
Copy link
Author

<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
Copy link
Owner

jbogard commented May 11, 2019

Related? Azure/azure-functions-host#3399

@jwyoung9
Copy link
Author

Ah - looks like it!

@jtemperv
Copy link

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

@jwisener
Copy link

Hitting the same issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants