From 4c16711f39dc4142d6ea951363ee93856038c8ff Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:04:07 +0800 Subject: [PATCH] mi-username --- src/azure-cli-core/azure/cli/core/_profile.py | 6 ------ .../cli/command_modules/profile/_breaking_change.py | 11 +++++++++++ .../azure/cli/command_modules/profile/custom.py | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/azure-cli/azure/cli/command_modules/profile/_breaking_change.py diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 7e1f20f5e37..d53fea946a9 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -61,11 +61,6 @@ _AZ_LOGIN_MESSAGE = "Please run 'az login' to setup account." -MANAGED_IDENTITY_ID_WARNING = ( - "Passing the managed identity ID with --username is deprecated and will be removed in a future release. " - "Please use --client-id, --object-id or --resource-id instead." -) - def load_subscriptions(cli_ctx, all_clouds=False, refresh=False): profile = Profile(cli_ctx=cli_ctx) @@ -257,7 +252,6 @@ def login_with_managed_identity(self, identity_id=None, client_id=None, object_i msi_creds = MSIAuthenticationWrapper(resource=resource, msi_res_id=resource_id) # The old way of re-using the same --username for 3 types of ID elif identity_id: - logger.warning(MANAGED_IDENTITY_ID_WARNING) if is_valid_resource_id(identity_id): msi_creds = MSIAuthenticationWrapper(resource=resource, msi_res_id=identity_id) identity_type = MsiAccountTypes.user_assigned_resource_id diff --git a/src/azure-cli/azure/cli/command_modules/profile/_breaking_change.py b/src/azure-cli/azure/cli/command_modules/profile/_breaking_change.py new file mode 100644 index 00000000000..0b2819cb739 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/profile/_breaking_change.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core.breaking_change import register_conditional_breaking_change, AzCLIOtherChange + +register_conditional_breaking_change(tag='ManagedIdentityUsernameBreakingChange', breaking_change=AzCLIOtherChange( + 'login', + 'Passing the managed identity ID with --username is deprecated and will be removed in 2.73.0. ' + 'Use --client-id, --object-id or --resource-id instead.')) diff --git a/src/azure-cli/azure/cli/command_modules/profile/custom.py b/src/azure-cli/azure/cli/command_modules/profile/custom.py index 9623657761a..4b8382188c5 100644 --- a/src/azure-cli/azure/cli/command_modules/profile/custom.py +++ b/src/azure-cli/azure/cli/command_modules/profile/custom.py @@ -143,6 +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() + if username: + from azure.cli.core.breaking_change import print_conditional_breaking_change + print_conditional_breaking_change(cmd.cli_ctx, tag='ManagedIdentityUsernameBreakingChange') 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)