Skip to content

FIX: Use the ai.azure.com audience for Azure AI identity auth - #4786

Merged
Behnam (behnam-o) merged 2 commits into
microsoft:mainfrom
behnam-o:fix/foundry-project-identity-audience
Dec 1, 2026
Merged

Behnam (behnam-o) merged 2 commits into
microsoft:mainfrom
behnam-o:fix/foundry-project-identity-audience

Conversation

@behnam-o

@behnam-o Behnam (behnam-o) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Identity auth requested a https://cognitiveservices.azure.com token. AI Foundry project endpoints (*.services.ai.azure.com/api/projects/...) reject it with a 401 and accept only https://ai.azure.com.

  • get_default_azure_scope now returns https://ai.azure.com/.default, which Azure OpenAI, Foundry resource and project endpoints, and Content Safety all accept (Azure OpenAI v1 docs).
  • Speech rejects that audience, so it explicitly keeps the Cognitive Services scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:19

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.

🟢 Approval recommended

No active review issues were identified for the endpoint-based Azure authentication scope change.

No open issues 🎉

What changed in this PR

Fixes Azure identity authentication for Foundry project endpoints by selecting the required https://ai.azure.com/.default scope while preserving the Cognitive Services scope for other endpoints.

Changes:

  • Selects the token audience using the parsed endpoint hostname and project path.
  • Adds parameterized tests for project endpoints, case variations, other hosts, and empty input.
File Description
tests/​unit/​auth/​test_azure_auth.py Tests endpoint-based audience selection and fallback behavior.
pyrit/​auth/​azure_auth.py Adds Foundry project scope selection and updates its documentation.

Review effort: Balanced

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

…peech

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@behnam-o Behnam (behnam-o) changed the title FIX: Use the ai.azure.com audience for Foundry project endpoints FIX: Use the ai.azure.com audience for Azure AI identity auth Dec 1, 2026
@behnam-o
Behnam (behnam-o) added this pull request to the merge queue Dec 1, 2026
Merged via the queue into microsoft:main with commit 7fccff9 Dec 1, 2026
114 of 118 checks passed
@behnam-o
Behnam (behnam-o) deleted the fix/foundry-project-identity-audience branch December 1, 2026 23:07
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.

3 participants