Repository navigation
Support TenantId and AuthorityHost in APPLICATIONINSIGHTS_AUTHENTICATION_STRING - #4892
Open
Rajkumar Rangaraj (rajkumar-rangaraj) wants to merge 2 commits into
Open
Rajkumar Rangaraj (rajkumar-rangaraj) wants to merge 2 commits into
Rajkumar Rangaraj (rajkumar-rangaraj) wants to merge 2 commits into
Conversation
…ION_STRING Client secret authentication configured via APPLICATIONINSIGHTS_AUTHENTICATION_STRING always failed validation because there was no way to provide the tenant id. Fixes #4891 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Rajkumar Rangaraj (rajkumar-rangaraj)
November 12, 2026 00:06
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The tenant ID error guidance should direct users of APPLICATIONINSIGHTS_AUTHENTICATION_STRING to update that variable, since it overrides the JSON authentication section and makes the suggested JSON fix ineffective.
1 open issue
What changed in this PR
Fixes #4891 by allowing the Java agent’s environment-based client-secret authentication to supply the required tenant ID and an optional authority host.
Changes:
- Parse
TenantIdandAuthorityHostfromAPPLICATIONINSIGHTS_AUTHENTICATION_STRING. - Update authentication warnings, validation guidance, and configuration comments.
- Extend regression tests to validate authentication configurations and document the fix.
| File | Description |
|---|---|
CHANGELOG.md |
Records the environment-based authentication fix. |
agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java |
Covers missing tenant IDs and valid configurations with optional authority hosts. |
agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java |
Reads the new fields and updates the deprecation warning example. |
agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java |
Updates missing-tenant guidance and the authentication example comment. |
Review effort: Max
Comment on lines
+1622
to
+1623
| "Please provide a valid \"tenantId\" under the \"authentication\" configuration, " | ||
| + "or add \"TenantId={TENANT_ID}\" to the APPLICATIONINSIGHTS_AUTHENTICATION_STRING environment variable. " |
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.

Fix #4891 .
APPLICATIONINSIGHTS_AUTHENTICATION_STRING=Authorization=AAD;ClientId=...;ClientSecret=...(the replacement recommended by theclientSecretJSON deprecation warning) could never work:overlayAadEnvVarsreplaces the wholeauthenticationsection and never setstenantId, soAadAuthentication.validate()always failed withmissing "tenantId"(andClientSecretCredentialBuilderrequires it anyway).Changes:
TenantIdand optionalAuthorityHostfromAPPLICATIONINSIGHTS_AUTHENTICATION_STRINGwhenClientSecretis present, e.g.Authorization=AAD;ClientId={CLIENT_ID};ClientSecret={CLIENT_SECRET};TenantId={TENANT_ID}clientSecretdeprecation warning example and the missing-tenantIderror message to mentionTenantIdshouldOverrideAadAuthenticationConfigto coverTenantId/AuthorityHostand to callvalidate()(the previous test didn't, which is why this wasn't caught)Validation:
./gradlew :agent:agent-tooling:spotlessApply :agent:agent-tooling:test --tests "*ConfigurationTest": passed (46 tests, 0 failures)For significant contributions please make sure you have completed the following items: