question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE REQ] Provide access to IServiceProvider in AddAzureClients method.

See original GitHub issue

Library or service name. Microsoft.Extensions.Azure

Is your feature request related to a problem? Please describe. There is no way in the AddAzureClients method to retrieve a class already registered (with the GetService or GetRequiredService methods of IServiceProvider). That is preventing us to retrieve a registered IOptions configuration. In an ASP.NET Core application, we are often grouping settings in IOptions configuration classes that are registered in depencency injection. But we can’t use them here and have to manually retrieve the expected settings from the Configuration object. Moreover with Azure Functions DI, there is currently no direct access to IConfiguration in FunctionStartup class, so it’s not possible to use AddAzureClients.

What feature would you like to get added? What problem is it solving? ServiceProvider shoud be available as a property of AzureClientFactoryBuilder or there should be an override to Add.AzureClients that accept a Action<AzureClientFactoryBuilder, IServiceProvider>.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
pakrymcommented, Apr 6, 2020

I was thinking about something like

services.AddAzureClients(builder =>

builder.AddClient<SomeClient>((options, provider) => new SomeClient(...., options));

);

It would work for client of any type and allow you to use service provider as part of client construction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency injection with the Azure SDK for .NET
Learn how to use dependency injection with the Azure SDK for .NET client libraries.
Read more >
Use dependency injection in .NET Azure Functions
Learn how to use dependency injection for registering and using services in .NET functions.
Read more >
How to resolve IOptions instance inside ConfigureServices?
Calling 'BuildServiceProvider' from application code results in an additional copy of singleton services being created. Consider alternatives ...
Read more >
ASP.NET Core Dependency Injection - Steve Gordon
In this post, I explain what an IServiceProvider is and how it can be created and later used to resolve dependencies in ASP.NET...
Read more >
New dependency injection features in .NET 6
In this post I talk about some of the new features added to the DI libraries in .NET 6, as well a performance...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found