-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] PREVIEW: Support managed identity on Azure Arc-enabled Windows server #29187
Conversation
️✔️AzureCLI-FullTest
|
Hi @jiasli, |
️✔️AzureCLI-BreakingChangeTest
|
Support managed identity on Azure Arc |
def _on_azure_arc(): | ||
return "IDENTITY_ENDPOINT" in os.environ and "IMDS_ENDPOINT" in os.environ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The detection condition is borrowed from MSAL: https://github.com/AzureAD/microsoft-authentication-library-for-python/pull/480/files#diff-24c0727ff4626c6c535d05c13b61fa4b4a47d6fc4496ec0ceadc734191de19cbR367
However, as mentioned in AzureAD/microsoft-authentication-library-for-python#480 (comment), it is fragile.
As mentioned in MSAL: https://github.com/AzureAD/microsoft-authentication-library-for-python/pull/480/files#diff-24c0727ff4626c6c535d05c13b61fa4b4a47d6fc4496ec0ceadc734191de19cbR367-R378
|
# Azure Arc | ||
if "IDENTITY_ENDPOINT" in os.environ and "IMDS_ENDPOINT" in os.environ: | ||
logger.debug("Azure Arc detected") | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These env vars may not be present on Linux servers, so MSAL introduced a new detection method: AzureAD/microsoft-authentication-library-for-python#731.
After a new MSAL is released, we should switch to _get_arc_endpoint
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update to use _get_arc_endpoint
now since new MSAL has been released for some time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msal.managed_identity._get_arc_endpoint
is a protected method. I have switched to msal.managed_identity.get_managed_identity_source
.
Azure Pipelines successfully started running 3 pipeline(s). |
Use Azure VM's managed identity in local developmentThis method is inspired by https://msal-python.readthedocs.io/en/latest/#msal.ManagedIdentityClient As Azure CLI still uses request_uri = 'http://localhost:8000/metadata/identity/oauth2/token' Then create a port forwarding using the
Now we can run some testing commands locally using the managed identity of the VM, without configuring Azure CLI's dev environment in the VM:
|
Related command
az login --identity
Description
az login --identity
for Azure Arc #16573This is only a temporary solution.
If Azure Arc is detected, Azure CLI uses MSAL for managed identity authentication. For other platforms, such as VM and App Service, the existing logic is preserved. These platforms' migration will be done in #25959.