Skip to content

[agentserver] Use system-assigned managed identity for Entra Azure Monitor auth#48097

Open
singankit wants to merge 1 commit into
mainfrom
singankit/agentserver-entra-auth-mode
Open

[agentserver] Use system-assigned managed identity for Entra Azure Monitor auth#48097
singankit wants to merge 1 commit into
mainfrom
singankit/agentserver-entra-auth-mode

Conversation

@singankit

Copy link
Copy Markdown
Contributor

Summary

When APPLICATIONINSIGHTS_CONNECTION_STRING is set and APPLICATIONINSIGHTS_AUTH_MODE is Entra, the microsoft-opentelemetry distro is now configured with a ManagedIdentityCredential (instantiated without a client id, i.e. the system-assigned identity) as the Azure Monitor exporter credential.

This follows the distro README guidance for Entra-based Azure Monitor auth via the azure_monitor_exporter_credential keyword.

Changes

  • core/_tracing.py (_setup_distro_export): reads APPLICATIONINSIGHTS_AUTH_MODE; on entra (case-insensitive) adds azure_monitor_exporter_credential.
  • New helper _create_managed_identity_credential(): lazily imports azure.identity.ManagedIdentityCredential (not a hard dependency) and returns None with a warning if unavailable, so setup degrades gracefully.
  • core/_constants.py: added the APPLICATIONINSIGHTS_AUTH_MODE well-known env var.
  • tests/test_tracing.py: added TestEntraAuthMode coverage.

Testing

pytest tests/test_tracing.py -k "Distro or Entra" — 6 passed.

When APPLICATIONINSIGHTS_CONNECTION_STRING is set and APPLICATIONINSIGHTS_AUTH_MODE
is Entra, pass a ManagedIdentityCredential (no client id) as the Azure Monitor
exporter credential to the microsoft-opentelemetry distro.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3c15f03b-e6c3-49d7-ae4b-c0bef594022e
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the Hosted Agents sdk/agentserver/* label Jul 16, 2026
@singankit
singankit marked this pull request as ready for review July 16, 2026 21:09
@singankit
singankit requested a review from ankitbko as a code owner July 16, 2026 21:09
Copilot AI review requested due to automatic review settings July 16, 2026 21:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds system-assigned managed identity authentication for Azure Monitor telemetry.

Changes:

  • Detects Entra authentication mode.
  • Creates a lazy ManagedIdentityCredential.
  • Adds focused tracing tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
_tracing.py Configures managed identity authentication.
_constants.py Defines the auth-mode environment variable.
test_tracing.py Tests Entra credential wiring.

Comment on lines +254 to +256
credential = _create_managed_identity_credential()
if credential is not None:
kwargs["azure_monitor_exporter_credential"] = credential
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants