Open
[DO NOT MERGE] Allow Azure Arc managed identity requests to forward user-assigned identity selectors#944
Conversation
Copilot
AI
changed the title
[WIP] [DO NOT MERGE] Add support for user-assigned managed identity in MSAL Python
[DO NOT MERGE] Allow Azure Arc managed identity requests to forward user-assigned identity selectors
Jul 15, 2026
gladjohn
marked this pull request as ready for review
July 16, 2026 02:24
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure Arc managed identity flow in MSAL Python to allow forwarding user-assigned identity selectors (client ID, resource ID, object ID) instead of rejecting user-assigned managed identities on Arc. It threads the managed_identity input into the Arc request path and maps resource_id to Arc/App Service’s expected wire name mi_res_id for both the challenge and authenticated HTTP calls.
Changes:
- Remove the Arc-only rejection of
UserAssignedManagedIdentityand passmanaged_identityinto_obtain_token_on_arc(...). - Add Arc-specific selector parameter mapping (including
resource_id→mi_res_id) on both Arc HTTP requests. - Update tests to validate selectors are forwarded for Arc user-assigned MI (client_id, mi_res_id, object_id) on both Arc calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
msal/managed_identity.py |
Allows Arc MI token acquisition to include user-assigned selector parameters (with Arc-specific mapping) on both Arc HTTP calls. |
tests/test_mi.py |
Replaces the “user-assigned not supported on Arc” expectation with happy-path tests asserting selector forwarding on both Arc requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4gust
approved these changes
Jul 16, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 593fce2a-8559-422e-92e2-46fb29c251a4
Comment on lines
+94
to
+96
| - script: | | ||
| apt-get update && apt-get install -y python3 python3-pip python3-venv | ||
| displayName: 'Install Python 3' |
Comment on lines
+93
to
100
| - script: python --version | ||
| displayName: 'Check Python version' | ||
|
|
||
| - script: | | ||
| python -m pip install --upgrade pip build twine | ||
| - script: python -m pip install --upgrade pip build twine | ||
| displayName: 'Install build toolchain' | ||
|
|
||
| - script: | | ||
| python -m build | ||
| - script: python -m build | ||
| displayName: 'Build sdist and wheel' |
Comment on lines
95
to
99
| - script: python --version | ||
| displayName: 'Check Python version' | ||
|
|
||
| - script: | | ||
| python -m pip install --upgrade pip build twine | ||
| - script: python -m pip install --upgrade pip build | ||
| displayName: 'Install build toolchain' |
Comment on lines
+137
to
140
| buildType: 'current' | ||
| artifactName: 'drop_Build_BuildDist' | ||
| targetPath: $(Pipeline.Workspace)\python-dist | ||
|
|
Comment on lines
129
to
135
| - task: DownloadPipelineArtifact@2 | ||
| displayName: 'Download build artifact' | ||
| inputs: | ||
| artifactName: drop_Build_BuildDist | ||
| targetPath: $(Pipeline.Workspace)/python-dist | ||
| buildType: 'current' | ||
| artifactName: 'drop_Build_BuildDist' | ||
| targetPath: $(Pipeline.Workspace)\python-dist | ||
|
|
Comment on lines
+93
to
97
| - script: python --version | ||
| displayName: 'Check Python version' | ||
|
|
||
| - script: | | ||
| python -m pip install --upgrade pip build twine | ||
| displayName: 'Install build toolchain' | ||
|
|
||
| - script: | | ||
| python -m build | ||
| - script: python setup.py sdist bdist_wheel | ||
| displayName: 'Build sdist and wheel' |
Comment on lines
81
to
97
| - stage: Build | ||
| displayName: 'Build package' | ||
| dependsOn: E2ETests | ||
| condition: eq(dependencies.E2ETests.result, 'Succeeded') | ||
| jobs: | ||
| - job: BuildDist | ||
| displayName: 'Build sdist + wheel (Python 3.12)' | ||
| displayName: 'Build sdist + wheel' | ||
| pool: | ||
| type: linux | ||
| isCustom: true | ||
| vmImage: 'ubuntu-22.04' | ||
| type: windows | ||
| variables: | ||
| ob_outputDirectory: '$(Build.ArtifactStagingDirectory)' | ||
| steps: | ||
| - task: UsePythonVersion@0 | ||
| inputs: | ||
| versionSpec: '3.12' | ||
| displayName: 'Use Python 3.12' | ||
| - script: python --version | ||
| displayName: 'Check Python version' | ||
|
|
||
| - script: | | ||
| python -m pip install --upgrade pip build twine | ||
| displayName: 'Install build toolchain' | ||
|
|
||
| - script: | | ||
| python -m build | ||
| - script: python setup.py sdist bdist_wheel | ||
| displayName: 'Build sdist and wheel' |
Comment on lines
+96
to
97
| - script: python setup.py sdist bdist_wheel | ||
| displayName: 'Build sdist and wheel' |
Comment on lines
129
to
135
| - task: DownloadPipelineArtifact@2 | ||
| displayName: 'Download build artifact' | ||
| inputs: | ||
| artifactName: drop_Build_BuildDist | ||
| targetPath: $(Pipeline.Workspace)/python-dist | ||
| buildType: 'current' | ||
| artifactName: 'drop_Build_BuildDist' | ||
| targetPath: $(Pipeline.Workspace)\python-dist | ||
|
|
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.
Azure Arc now previews user-assigned managed identity support. This change aligns MSAL Python with that behavior by removing the Arc-only rejection path and forwarding the selected identity on Arc token requests.
Will be released as preview: version = "1.38.0rc2"
Azure Arc request flow
UserAssignedManagedIdentity.managed_identityinto_obtain_token_on_arc(...).client_idmi_res_idobject_idParameter mapping
_adjust_param(...)helper with an explicit Arc/App Service-style mapping so resource IDs are sent asmi_res_idrather than the defaultresource_id.Tests
client_idresource_id→mi_res_idobject_id