Azure-webjobs-sdk: Document how AddScoped works to be per function calls

Created on 12 Apr 2019  路  2Comments  路  Source: Azure/azure-webjobs-sdk

Even though as it seems to have been fixed, no information has been provided regarding how to use AddScoped properly per function calls.

The original bug is here:
https://github.com/Azure/azure-webjobs-sdk/issues/1950

After a full month, we have received no answers, no commits, no documentation explaining how this works.

I am opening this bug as an actionable item for the team to respond properly.

Most helpful comment

Just a heads up: AddScoped is not fixed as far as I can tell. I still am getting my dependencies behaving like singletons.

All 2 comments

Just a heads up: AddScoped is not fixed as far as I can tell. I still am getting my dependencies behaving like singletons.

I can confirm this issue is not fixed in v3.0.6 (of Webjobs.Extensions.Storage BlobTrigger)

Edit: this appears to be working when adding scoped dependencies manually, I am running into an issue with this code always returns the same instance of CustomUserManager

builder.Services
                .AddIdentityCore<CustomUser>()
                .AddEntityFrameworkStores<CustomUserDBContext>()
                .AddUserManager<CustomUserManager>()

Edit 2: Registering like this respects scoping as expected

            builder.Services
                .AddIdentityCore<CustomUser>()
                .AddEntityFrameworkStores<CustomUserDBContext>();
            builder.Services.AddScoped(typeof(CustomUserManager));
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-netdev picture sergey-netdev  路  5Comments

fwd079 picture fwd079  路  5Comments

mslugx picture mslugx  路  3Comments

giotab picture giotab  路  5Comments

kamranayub picture kamranayub  路  4Comments