@@ -220,16 +220,8 @@ def login(self,
220220 self ._set_subscriptions (consolidated )
221221 return deepcopy (consolidated )
222222
223- def login_with_managed_identity (self , identity_id = None , client_id = None , object_id = None , resource_id = None ,
224- allow_no_subscriptions = None ):
225- if _use_msal_managed_identity (self .cli_ctx ):
226- if identity_id :
227- raise CLIError ('--username is not supported by MSAL managed identity. '
228- 'Use --client-id, --object-id or --resource-id instead.' )
229- return self .login_with_managed_identity_msal (
230- client_id = client_id , object_id = object_id , resource_id = resource_id ,
231- allow_no_subscriptions = allow_no_subscriptions )
232-
223+ def login_with_managed_identity_msrestazure (
224+ self , identity_id = None , client_id = None , object_id = None , resource_id = None , allow_no_subscriptions = None ):
233225 import jwt
234226 from azure .mgmt .core .tools import is_valid_resource_id
235227 from azure .cli .core .auth .adal_authentication import MSIAuthenticationWrapper
@@ -308,8 +300,13 @@ def login_with_managed_identity(self, identity_id=None, client_id=None, object_i
308300 self ._set_subscriptions (consolidated )
309301 return deepcopy (consolidated )
310302
311- def login_with_managed_identity_msal (self , client_id = None , object_id = None , resource_id = None ,
303+ def login_with_managed_identity (self , client_id = None , object_id = None , resource_id = None ,
312304 allow_no_subscriptions = None ):
305+ if not _use_msal_managed_identity (self .cli_ctx ):
306+ return self .login_with_managed_identity_msrestazure (
307+ client_id = client_id , object_id = object_id , resource_id = resource_id ,
308+ allow_no_subscriptions = allow_no_subscriptions )
309+
313310 import jwt
314311 from .auth .constants import ACCESS_TOKEN
315312
0 commit comments