-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Profile] Drop support for old-style managed identity account #30321
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
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
CI failed: I don't think this detection is correct. |
|
I am temporarily altering the history notes to bypass the incorrect detection logic. After the PR is merged, I will change it back:
|
| if parts[0] in MsiAccountTypes.valid_msi_account_types(): | ||
| return parts[0], (None if len(parts) <= 1 else parts[1]) | ||
| def _parse_managed_identity_account(account): | ||
| user_name = account[_USER_ENTITY][_USER_NAME] |
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.
_USER_NAME must exist:
azure-cli/src/azure-cli-core/azure/cli/core/_profile.py
Lines 491 to 494 in 77f14ba
| _USER_ENTITY: { | |
| _USER_NAME: user, | |
| _USER_TYPE: _SERVICE_PRINCIPAL if is_service_principal else _USER | |
| }, |
There is no need to use get().
| # The account contains: | ||
| # "assignedIdentityInfo": "MSIClient-xxx"/"MSIObject-xxx"/"MSIResource-xxx", | ||
| # "name": "userAssignedIdentity", | ||
| return tuple(account[_USER_ENTITY][_ASSIGNED_IDENTITY_INFO].split('-', maxsplit=1)) |
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.
If _USER_NAME is _SYSTEM_ASSIGNED_IDENTITY or _USER_ASSIGNED_IDENTITY, _ASSIGNED_IDENTITY_INFO must exist:
azure-cli/src/azure-cli-core/azure/cli/core/_profile.py
Lines 276 to 285 in 77f14ba
| user = _USER_ASSIGNED_IDENTITY if identity_id else _SYSTEM_ASSIGNED_IDENTITY | |
| if not subscriptions: | |
| if allow_no_subscriptions: | |
| subscriptions = self._build_tenant_level_accounts([tenant]) | |
| else: | |
| raise CLIError('No access was configured for the VM, hence no subscriptions were found. ' | |
| "If this is expected, use '--allow-no-subscriptions' to have tenant level access.") | |
| consolidated = self._normalize_properties(user, subscriptions, is_service_principal=True, | |
| user_assigned_identity_id=base_name) |
| test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590' | ||
| test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234' | ||
| test_user = 'systemAssignedIdentity' | ||
| msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSI', self.state1, test_tenant_id) |
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.
Test cases still use subscription name to store the managed identity info.
Related command
az loginDescription
This PR is separated from #25959 (comment)
In versions <= 2.0.50 (released on November 6, 2018),
_SUBSCRIPTION_NAMEis used to denote the managed identity ID info (_ASSIGNED_IDENTITY_INFO). This is a bad design, as an Azure subscription has its own name. So,_ASSIGNED_IDENTITY_INFOwas added in #7744 to give way to the real subscription name and_try_parse_msi_account_name()acts as an adaptor. However, such logic is difficult to maintain. Even its creator admits:As it has been 6 years since 2.0.50, and Azure CLI is self-consistent, this should not be considered a breaking change.
Testing Guide
History Notes
[Profile] Drop support for old-style managed identity account created by Azure CLI <= 2.0.50. If you upgrade from one of these versions, please run
az login --identityagain.