Connection String env var - base, web, nlog#3134
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds connection-string resolution via the standard APPLICATIONINSIGHTS_CONNECTION_STRING environment variable when a connection string isn’t provided programmatically, aligning BASE and NLog target behavior with common Azure Monitor configuration patterns.
Changes:
- NLog target (
ApplicationInsightsTarget) now falls back toAPPLICATIONINSIGHTS_CONNECTION_STRINGif the configured layout renders empty/whitespace. - BASE
TelemetryConfiguration.Build()now readsAPPLICATIONINSIGHTS_CONNECTION_STRINGwhenConnectionStringwas not set in code, and avoids setting exporter options when the value is empty. - BASE
InitializeFeatureReporter()now short-circuits whenconnectionStringis empty (but this introduces a correctness risk; see comments).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs | Adds env-var fallback for the NLog target connection string during initialization. |
| BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs | Adds env-var fallback during OTel SDK build and adjusts exporter option assignment / feature reporter initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
rajkumar-rangaraj
approved these changes
Mar 3, 2026
Member
mattsains-msft
left a comment
There was a problem hiding this comment.
Other than the first LLM-generated comment, I think this PR is good to go. Will approve after that's resolved
xiang17
reviewed
Mar 3, 2026
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs
Show resolved
Hide resolved
harsimar
added a commit
that referenced
this pull request
Apr 1, 2026
This was referenced Apr 2, 2026
Open
Closed
Open
This was referenced Apr 5, 2026
Merged
Merged
Open
Bump Microsoft.ApplicationInsights.WorkerService from 3.0.0 to 3.1.0
mspnp/cloud-design-patterns#473
Merged
Open
Open
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds code to fall back to the env var for connection string if it isn't set via code for the BASE, WEB, NLogTarget packages.
Tested by setting a system env var then running example apps in repo with code config for connection string removed.