Skip to content

fix(azure_sentinel): add AZURE_SENTINEL_AUTHORITY_HOST as a Sentinel scoped override - #36165

Merged
yucheng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_azure_sentinel_authority_override
Aug 7, 2026
Merged

fix(azure_sentinel): add AZURE_SENTINEL_AUTHORITY_HOST as a Sentinel scoped override#36165
yucheng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_azure_sentinel_authority_override

Conversation

@yucheng-berri

@yucheng-berri yucheng-berri commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • fix(azure_sentinel): respect AZURE_AUTHORITY_HOST and derive the Azure Monitor audience per cloud #36137 made Azure Sentinel follow AZURE_AUTHORITY_HOST, which is shared with Azure OpenAI and the azure_storage callback. That is a breaking change for a deployment that sets the shared variable for one of those while keeping a commercial Sentinel workspace
  • Such a deployment currently has no opt-out. The proxy constructs AzureSentinelLogger() with no arguments at litellm/litellm_core_utils/litellm_logging.py:3692, so the authority_host constructor parameter is reachable only from the SDK

How it solves it:

  • The authority now resolves from AZURE_SENTINEL_AUTHORITY_HOST before AZURE_AUTHORITY_HOST, matching how tenant_id, client_id and client_secret already resolve three lines above in the same constructor
  • Set AZURE_SENTINEL_AUTHORITY_HOST=https://login.microsoftonline.com to keep Sentinel on the commercial cloud while the rest of your Azure resources use a sovereign authority
  • No behavior change for anyone who does not set the new variable

Relevant issues

Follow-up to #36137

Linear ticket

Merge order

BerriAI/litellm-docs#813 must merge first. tests/documentation_tests/test_env_keys.py checks out litellm-docs at its default branch and fails any env var read under litellm/ that is not documented there, so documentation and code-quality stay red until it lands.

Pre-Submission checklist

Screenshots / Proof of Fix

Real proxy, real Postgres, real Gemini call driving the callback, real Microsoft Entra, and the same real Azure Monitor Data Collection Endpoint used to verify #36137. Tenant id redacted.

export AZURE_SENTINEL_ENDPOINT="https://litellm-lit5293-dce-yv7r.eastus-1.ingest.monitor.azure.com"
export AZURE_SENTINEL_DCR_IMMUTABLE_ID=...  AZURE_SENTINEL_TENANT_ID=...  AZURE_SENTINEL_CLIENT_ID=...  AZURE_SENTINEL_CLIENT_SECRET=...
export AZURE_AUTHORITY_HOST="https://login.microsoftonline.us"          # sovereign, for the other Azure integrations
export AZURE_SENTINEL_AUTHORITY_HOST="https://login.microsoftonline.com" # commercial, for Sentinel only

python -m litellm.proxy.proxy_cli --config config.yaml --port 20310 --use_prisma_db_push --detailed_debug
curl -sS http://127.0.0.1:20310/v1/chat/completions -H "Authorization: Bearer sk-1234" \
  -H "Content-Type: application/json" -d '{"model":"gemini-flash","messages":[{"role":"user","content":"hi"}]}'
leg tree AZURE_AUTHORITY_HOST AZURE_SENTINEL_AUTHORITY_HOST token request Azure ingestion
1 base gov commercial override ignored, goes to login.microsoftonline.us, 400 none
2 head gov commercial override honored, token issued 204
3 head gov unset follows the shared variable, login.microsoftonline.us, 400 none

Leg 1 against leg 2 is the fix: the breaking change from #36137 becomes remediable, confirmed by a real 204 from Azure Monitor. Leg 3 is the guard: with no override, the behavior shipped in #36137 is untouched.

Type

🐛 Bug Fix

Changes

litellm/integrations/azure_sentinel/azure_sentinel.py reads one additional environment variable in the authority resolution chain. No other file changes.

On the Azure Government authority alias

azure-identity groups login.usgovcloudapi.net with AZURE_GOVERNMENT in its token-cache alias set, so mapping it looked worthwhile. It was implemented and then removed. That host resolves to genuine Azure Government identity infrastructure and answers as Entra with AADSTS90038 when certificate validation is disabled, but it presents no TLS certificate covering its own name, so a normal client cannot connect at all. Mapping it would advertise a configuration that cannot work, behind a unit test that would pass regardless.

QA runbook

  1. With AZURE_AUTHORITY_HOST unset, confirm Sentinel logging still reaches a commercial workspace exactly as before
  2. Set AZURE_AUTHORITY_HOST to the Azure Government authority and confirm the token request moves to login.microsoftonline.us
  3. Add AZURE_SENTINEL_AUTHORITY_HOST=https://login.microsoftonline.com and confirm Sentinel returns to the commercial authority while the shared variable stays sovereign

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Open in Devin Review

Note

Low Risk
Narrow logging-integration config change with backward-compatible fallback order and targeted unit tests; no auth or data-path changes outside Sentinel OAuth token acquisition.

Overview
Adds AZURE_SENTINEL_AUTHORITY_HOST to the Entra authority resolution chain in AzureSentinelLogger, checked after the authority_host constructor argument and before the shared AZURE_AUTHORITY_HOST. Deployments can point Sentinel at a different cloud (e.g. commercial Sentinel while other Azure integrations use a sovereign authority) without changing behavior when the new variable is unset.

Tests cover precedence: Sentinel-scoped env beats shared env, shared env still applies when the Sentinel var is missing, and an explicit constructor authority_host beats the scoped env. The authority-host test fixture now clears AZURE_SENTINEL_AUTHORITY_HOST so cases stay isolated.

Reviewed by Cursor Bugbot for commit 66c00a8. Bugbot is set up for automated code reviews on this repo. Configure here.

…scoped override

Making Sentinel follow AZURE_AUTHORITY_HOST is a breaking change for a
deployment that sets that variable for Azure OpenAI or the azure_storage
callback while keeping a commercial Sentinel workspace. That deployment had no
opt-out, because the proxy constructs the logger with no arguments and the
authority_host parameter is reachable only from the SDK.

Resolve the authority from AZURE_SENTINEL_AUTHORITY_HOST before falling back to
AZURE_AUTHORITY_HOST, matching how tenant id, client id and client secret
already resolve in this constructor.

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a Sentinel-scoped Azure authority override while preserving explicit-argument precedence and fallback to the shared Azure authority

  • Resolves AZURE_SENTINEL_AUTHORITY_HOST before AZURE_AUTHORITY_HOST
  • Keeps the selected authority and Azure Monitor OAuth audience aligned
  • Adds focused tests for scoped precedence, shared fallback, and explicit constructor overrides

Confidence Score: 5/5

The PR appears safe to merge, with the scoped override correctly propagated to the existing token-request path

The new environment variable has the intended precedence, preserves existing defaults and explicit arguments, and feeds the same authority and audience attributes already used by OAuth requests

Important Files Changed

Filename Overview
litellm/integrations/azure_sentinel/azure_sentinel.py Adds the scoped authority environment variable to the existing resolution chain without changing downstream token or ingestion behavior
tests/test_litellm/integrations/test_azure_sentinel.py Adds meaningful precedence and fallback regression coverage while correctly isolating both authority environment variables

Reviews (1): Last reviewed commit: "fix(azure_sentinel): add AZURE_SENTINEL_..." | Re-trigger Greptile

@yucheng-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 66c00a8. Configure here.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_azure_sentinel_authority_override (66c00a8) with litellm_internal_staging (4b7adab)

Open in CodSpeed

@mateo-berri mateo-berri 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.

LGTM. Thanks!

@yucheng-berri
yucheng-berri merged commit bd289c1 into litellm_internal_staging Aug 7, 2026
82 of 84 checks passed
@yucheng-berri
yucheng-berri deleted the litellm_azure_sentinel_authority_override branch August 7, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants