Azure/azure-functions-dotnet-extensions

Request: a simple README.MD for the "Scopes" example, explaining what is EXPECTED when people hit the HTTP trigger

PureKrome opened this issue ยท 0 comments

๐Ÿ‘‹ Heya - just looking at the "Scopes" sample provided and I'm trying to understand the difference between transient and scoped life's with respect to Azure Functions. I totally grok it, with respect to an ASP.NET Core app + Request/Responses, etc.

It would be really nice if we could have a README.MD added to the scopes folder with example instructions & output. For example, the code says:

// Register MyServiceA as transient.
// A new instance will be returned every
// time a service request is made
builder.Services.AddTransient<MyServiceA>();

// Register MyServiceB as scoped.
// The same instance will be returned
// within the scope of a function invocation
builder.Services.AddScoped<MyServiceB>();

and the output for 1x HTTP request is:

{
"providersMatch": true,
"globalId": "db295a09-5458-4a60-a17e-ea538db8a586",
"serviceAId": "1678107f-c2e4-47eb-9514-0be4af5165dd",
"serviceBId": "1678107f-c2e4-47eb-9514-0be4af5165dd"
}

But I would have thought that serviceAId and serviceBId should be different?

So it would be really nice to explain how to see:

  • a transient in action
  • a scoped in action
  • a singleton in action

with steps showing how to replicate and confirm this is occurring.

๐Ÿ™ @fabiocav ๐Ÿ™