@@ -223,9 +223,6 @@ def login(self,
223223 def login_with_managed_identity (self , client_id = None , object_id = None , resource_id = None ,
224224 allow_no_subscriptions = None ):
225225 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.' )
229226 return self .login_with_managed_identity_msal (
230227 client_id = client_id , object_id = object_id , resource_id = resource_id ,
231228 allow_no_subscriptions = allow_no_subscriptions )
@@ -254,37 +251,6 @@ def login_with_managed_identity(self, client_id=None, object_id=None, resource_i
254251 identity_type = MsiAccountTypes .user_assigned_resource_id
255252 identity_id = resource_id
256253 msi_creds = MSIAuthenticationWrapper (resource = resource , msi_res_id = resource_id )
257- # The old way of re-using the same --username for 3 types of ID
258- elif identity_id :
259- if is_valid_resource_id (identity_id ):
260- msi_creds = MSIAuthenticationWrapper (resource = resource , msi_res_id = identity_id )
261- identity_type = MsiAccountTypes .user_assigned_resource_id
262- else :
263- authenticated = False
264- from azure .cli .core .azclierror import AzureResponseError
265- try :
266- msi_creds = MSIAuthenticationWrapper (resource = resource , client_id = identity_id )
267- identity_type = MsiAccountTypes .user_assigned_client_id
268- authenticated = True
269- except AzureResponseError as ex :
270- if 'http error: 400, reason: Bad Request' in ex .error_msg :
271- logger .info ('Sniff: not an MSI client id' )
272- else :
273- raise
274-
275- if not authenticated :
276- try :
277- identity_type = MsiAccountTypes .user_assigned_object_id
278- msi_creds = MSIAuthenticationWrapper (resource = resource , object_id = identity_id )
279- authenticated = True
280- except AzureResponseError as ex :
281- if 'http error: 400, reason: Bad Request' in ex .error_msg :
282- logger .info ('Sniff: not an MSI object id' )
283- else :
284- raise
285-
286- if not authenticated :
287- raise CLIError ('Failed to connect to MSI, check your managed service identity id.' )
288254
289255 token_entry = msi_creds .token
290256 token = token_entry ['access_token' ]
0 commit comments