Skip to content

Commit 6b28029

Browse files
authored
{Profile} az login: Announce --username breaking change for managed identity (#31061)
1 parent 69b379d commit 6b28029

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/azure-cli-core/azure/cli/core/_profile.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161

6262
_AZ_LOGIN_MESSAGE = "Please run 'az login' to setup account."
6363

64-
MANAGED_IDENTITY_ID_WARNING = (
65-
"Passing the managed identity ID with --username is deprecated and will be removed in a future release. "
66-
"Please use --client-id, --object-id or --resource-id instead."
67-
)
68-
6964

7065
def load_subscriptions(cli_ctx, all_clouds=False, refresh=False):
7166
profile = Profile(cli_ctx=cli_ctx)
@@ -257,7 +252,6 @@ def login_with_managed_identity(self, identity_id=None, client_id=None, object_i
257252
msi_creds = MSIAuthenticationWrapper(resource=resource, msi_res_id=resource_id)
258253
# The old way of re-using the same --username for 3 types of ID
259254
elif identity_id:
260-
logger.warning(MANAGED_IDENTITY_ID_WARNING)
261255
if is_valid_resource_id(identity_id):
262256
msi_creds = MSIAuthenticationWrapper(resource=resource, msi_res_id=identity_id)
263257
identity_type = MsiAccountTypes.user_assigned_resource_id
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from azure.cli.core.breaking_change import register_conditional_breaking_change, AzCLIOtherChange
7+
8+
register_conditional_breaking_change(tag='ManagedIdentityUsernameBreakingChange', breaking_change=AzCLIOtherChange(
9+
'login',
10+
'Passing the managed identity ID with --username is deprecated and will be removed in 2.73.0. '
11+
'Use --client-id, --object-id or --resource-id instead.'))

src/azure-cli/azure/cli/command_modules/profile/custom.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ def login(cmd, username=None, password=None, tenant=None, scopes=None, allow_no_
143143
if identity:
144144
if in_cloud_console():
145145
return profile.login_in_cloud_shell()
146+
if username:
147+
from azure.cli.core.breaking_change import print_conditional_breaking_change
148+
print_conditional_breaking_change(cmd.cli_ctx, tag='ManagedIdentityUsernameBreakingChange')
146149
return profile.login_with_managed_identity(
147150
identity_id=username, client_id=client_id, object_id=object_id, resource_id=resource_id,
148151
allow_no_subscriptions=allow_no_subscriptions)

0 commit comments

Comments
 (0)