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

Retrieve connection string from configuration by default #214

Open
kdewey13 opened this issue Jul 31, 2023 · 2 comments
Open

Retrieve connection string from configuration by default #214

kdewey13 opened this issue Jul 31, 2023 · 2 comments

Comments

@kdewey13
Copy link

Hello,

I am working on a solution containing both ASP.NET Core minimal APIs and Azure Functions. My organization is attempting to create very uniform application start up processes, and thus we attempt to use this Serilog sink in the same manner in both the APIs and functions. We provide the configuration from JSON config providers using ReadFrom.Configuration().

For the Azure functions, we can omit the connection string property from the Serilog WriteTo section of the configuration file. We do provide APPLICATIONINSIGHTS_CONNECTION_STRING property in the config, which is working for both the sink and when registering the telemetry collection. No additional code is needed for the azure functions to properly log to App Insights.

For the APIs, providing APPLICATIONINSIGHTS_CONNECTION_STRING in the config works for registration, but does not work for the sink. We are having to add an additional step to save the value from the config into an environment variable. Since neither the builder.Services.AddApplicationInsightsTelemetry() or Azure function serilog set up require this step, this is inconsistent.

Wondering if support can be added for retrieving the connection string from IConfiguration["APPLICATIONINSIGHTS_CONNECTION_STRING"] if not present in environment variable or provided in config directly?

@nblumhardt
Copy link
Contributor

Thanks for the write-up and suggestion. I'm not actively using this sink so something of a caretaker right now, and not sure what would be involved in implementing this. If you're keen to dig in further to figure out the impacts/possibly put together a PR, I can help to push it ahead.

@kdewey13
Copy link
Author

kdewey13 commented Aug 3, 2023

Ok great, I am not sure when I will have availability to do that, but I am really interest in doing so, so I will do my best to work it in, and I will comment back here if/when I can do so. Thanks so much!

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

No branches or pull requests

2 participants