Skip to content

Retrieve connection string from configuration by default #214

Open
@kdewey13

Description

@kdewey13

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions