Skip to content

[Feature Request] For managed identity authentication, replace --username with --client-id, --object-id and --resource-id  #29480

Description

@jiasli

Related command
az login --identity

Is your feature request related to a problem? Please describe.
As mentioned in AzureAD/microsoft-authentication-library-for-python#480 (comment), Azure CLI does not surface an "identity ID type" concept, therefore the usage pattern is based on trial-and-error:

authenticated = False
from azure.cli.core.azclierror import AzureResponseError
try:
msi_creds = MSIAuthenticationWrapper(resource=resource, client_id=identity_id)
identity_type = MsiAccountTypes.user_assigned_client_id
authenticated = True
except AzureResponseError as ex:
if 'http error: 400, reason: Bad Request' in ex.error_msg:
logger.info('Sniff: not an MSI client id')
else:
raise
if not authenticated:
try:
identity_type = MsiAccountTypes.user_assigned_object_id
msi_creds = MSIAuthenticationWrapper(resource=resource, object_id=identity_id)
authenticated = True
except AzureResponseError as ex:
if 'http error: 400, reason: Bad Request' in ex.error_msg:
logger.info('Sniff: not an MSI object id')
else:
raise
if not authenticated:
raise CLIError('Failed to connect to MSI, check your managed service identity id.')

Reusing --username for 3 types of IDs is inefficient and can be confusing to command readers (#29198 (comment)).

Describe the solution you'd like
Replace --username with --client-id, --object-id and --resource-id for managed identity authentication.

Describe alternatives you've considered

Additional context
--service-principal may require similar changes: #29481

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Accountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamSimilar-IssuequestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions