-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Profile] az login: Add --client-id, --object-id and --resource-id for user-assigned managed identity authentication
#30525
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,14 +114,14 @@ def account_clear(cmd): | |
| profile.logout_all() | ||
|
|
||
|
|
||
| # pylint: disable=inconsistent-return-statements, too-many-branches | ||
| # pylint: disable=too-many-branches, too-many-locals | ||
| def login(cmd, username=None, password=None, tenant=None, scopes=None, allow_no_subscriptions=False, | ||
| # Device code flow | ||
| use_device_code=False, | ||
| # Service principal | ||
| service_principal=None, certificate=None, use_cert_sn_issuer=None, client_assertion=None, | ||
| # Managed identity | ||
| identity=False): | ||
| identity=False, client_id=None, object_id=None, resource_id=None): | ||
| """Log in to access Azure subscriptions""" | ||
|
|
||
| # quick argument usage check | ||
|
|
@@ -143,7 +143,9 @@ def login(cmd, username=None, password=None, tenant=None, scopes=None, allow_no_ | |
| if identity: | ||
| if in_cloud_console(): | ||
| return profile.login_in_cloud_shell() | ||
| return profile.login_with_managed_identity(username, allow_no_subscriptions) | ||
| return profile.login_with_managed_identity( | ||
| identity_id=username, client_id=client_id, object_id=object_id, resource_id=resource_id, | ||
| allow_no_subscriptions=allow_no_subscriptions) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add a param validation that only one of the four (
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion. Added the validation logic into |
||
| if in_cloud_console(): # tell users they might not need login | ||
| logger.warning(_CLOUD_CONSOLE_LOGIN_WARNING) | ||
|
|
||
|
|
||
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 ID names are aligned with MSAL: https://learn.microsoft.com/en-us/entra/msal/python/advanced/managed-identity#user-assigned-managed-identities
client_id)resource_id) - inconsistent withmsrestazure'smsi_res_idobject_id)