Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable provider logging when running in Azure Functions #423

Open
zhenlan opened this issue May 16, 2023 · 6 comments
Open

Enable provider logging when running in Azure Functions #423

zhenlan opened this issue May 16, 2023 · 6 comments
Assignees

Comments

@zhenlan
Copy link
Contributor

zhenlan commented May 16, 2023

Azure Functions use ILogger, but our provider logging doesn't work out of the box today.

@zhenlan
Copy link
Contributor Author

zhenlan commented May 16, 2023

cc @avanigupta

@avanigupta
Copy link
Member

Is this specifically for isolated mode or in-process? Or both?

@zhenlan
Copy link
Contributor Author

zhenlan commented May 16, 2023

Both, if possible, but will prioritize the isolated mode if we have to choose.

@goldsam
Copy link

goldsam commented Dec 29, 2023

How could this have been broken? If you take an injected dependency on ILoggerFactory or ILogger<XXX>, wouldn't this have worked in any environment?

@zhiyuanliang-ms
Copy link
Contributor

zhiyuanliang-ms commented Jul 16, 2024

@goldsam
Copy link

goldsam commented Jul 17, 2024

@zhiyuanliang-ms

I see the issue and recognize this is a unique challenge. AzureAppConfigurationSource depends on services (indirectly via ConfigurationClientManager) that ideally would be injected such as ILoggerFactory/ILogger and ConfigurationClient.

Here are some ideas:

  • Introduce a Func<IServiceProvider> ServiceProviderResolver {get; set;} property on AzureAppConfigurationOptions that would be used to lazily resolve an ILoggerFactory (and perhaps the ConfigurationClient as well).
  • Introduce more specific callbacks such as Func<ILoggerFactory> LoggerFactoryResolver {get; set;}
  • Introduce extensions methods on IConfigurationBuilder to store state in IConfigurationBuilder.Properties that could be used to resolve these services.

There are things in ConfigurationClientManager that could be exposed as part of the public API via AzureAppConfigurationOptions to solve the problem.

I think the common use case is to build an IConfiguration to which IOptions are bound. When AddOptions and Configure extension methods are used, these options are lazily resolved at runtime. The implication is that lazy options binding would occur after application startup when the DI container exists and the dependent services are available.

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

No branches or pull requests

6 participants