Unable to run 'az ad user show --id [email protected]' on AzureML Ubuntu VM
Describe the bug
I want to get my Entra ID programmingly via az ad user show --id [email protected]. When I run it on an AzureML Ubuntu VM (I ssh to this VM from my Windows workstation), I am getting error below. The same command runs successfully on my Window workstation.
cli.azure.cli.core.azclierror: AADSTS530003: Your device is required to be managed to access this resource. Trace ID: 9e5ee058-55f2-43d4-8fdd-7ae130103000 Correlation ID: 12055c6b-cc04-4bce-a4d4-cab52a130fff Timestamp: 2024-06-29 06:24:36Z
az_command_data_logger: AADSTS530003: Your device is required to be managed to access this resource. Trace ID: 9e5ee058-55f2-43d4-8fdd-7ae130103000 Correlation ID: 12055c6b-cc04-4bce-a4d4-cab52a130fff Timestamp: 2024-06-29 06:24:36Z
Another related symptom. I can run az login --use-device-code successfully on the Ubuntu VM. But if I add the option --scope https://graph.microsoft.com//.default, I am getting error below. The option works fine on my Windows worksation az login --scope https://graph.microsoft.com//.default.
Related command
az ad user show --id [email protected]
az login --use-device-code --scope https://graph.microsoft.com//.default
Errors
See description above.
Issue script & Debug output
Here is the debug output for az ad user show --id [email protected] --debug
DEBUG: cli.knack.cli: Command arguments: ['ad', 'user', 'show', '--id', '[email protected]', '--debug']
DEBUG: cli.knack.cli: init debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x746a8570c040>, <function OutputProducer.on_global_arguments at 0x746a856b6200>, <function CLIQuery.on_global_arguments at 0x746a856f3ce0>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'ad': ['azure.cli.command_modules.role']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: role 0.004 17 61
DEBUG: cli.azure.cli.core: Total (1) 0.004 17 61
DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
DEBUG: cli.azure.cli.core: Loading extensions:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands Directory
DEBUG: cli.azure.cli.core: Total (0) 0.000 0 0
DEBUG: cli.azure.cli.core: Loaded 17 groups, 61 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : ad user show
DEBUG: cli.azure.cli.core: Command table: ad user show
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x746a84674e00>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/REDACT/.azure/commands/2024-06-29.06-51-17.ad_user_show.1062634.log'.
INFO: az_command_data_logger: command args: ad user show --id {} --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.
ERROR: cli.azure.cli.core.azclierror: AADSTS530003: Your device is required to be managed to access this resource. Trace ID: a3c52841-d43e-4d86-88e7-d0f2c3862b00 Correlation ID: 53263086-9034-477f-b299-66436a86d9d2 Timestamp: 2024-06-29 06:51:14Z ERROR: az_command_data_logger: AADSTS530003: Your device is required to be managed to access this resource. Trace ID: a3c52841-d43e-4d86-88e7-d0f2c3862b00 Correlation ID: 53263086-9034-477f-b299-66436a86d9d2 Timestamp: 2024-06-29 06:51:14Z Interactive authentication is needed. Please run: az login --scope https://graph.microsoft.com//.default DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x746a84675080>] INFO: az_command_data_logger: exit code: 1 INFO: cli.main: Command ran in 0.291 seconds (init: 0.148, invoke: 0.142) INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1 INFO: telemetry.client: Accumulated 0 events. Flush the clients. INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1 INFO: telemetry.save: Save telemetry record of length 3995 in cache INFO: telemetry.main: Begin creating telemetry upload process. INFO: telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/init.py /home/REDACT/.azure" INFO: telemetry.process: Return from creating process INFO: telemetry.main: Finish creating telemetry upload process.
Expected behavior
az ad user show --id [email protected] should run successfully on AzureML Ubuntu VM
Environment Summary
azure-cli 2.61.0 core 2.61.0 telemetry 1.1.0 Extensions: ml 2.26.1 Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1
Python location '/opt/az/bin/python3' Extensions directory '/home/REDACT/.azure/cliextensions' Python (Linux) 3.11.8 (main, May 16 2024, 03:47:28) [GCC 11.4.0] Legal docs and information: aka.ms/AzureCliLegal Your CLI is up-to-date.
Additional context
No response
Thank you for opening this issue, we will look into it.
https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes#aadsts-error-codes doesn't document AADSTS530003, but I guess it is the same issue as https://learn.microsoft.com/en-us/cli/azure/microsoft-graph-migration#graph-command-fails-with-aadsts50005-or-aadsts53000, that is, Microsoft tenant (72f988bf-86f1-41af-91ab-2d7cd011db47) doesn't allow using device code flow to access Microsoft Graph.
There is a feature request https://github.com/Azure/azure-cli/issues/22776 to show the signed in account's object ID, but that feature request was suspended due to several unsettled security discussions. You may follow https://github.com/Azure/azure-cli/issues/22776#issue-1264203875 to retrieve the object ID from the access token.
https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes#aadsts-error-codes doesn't document
AADSTS530003, but I guess it is the same issue as https://learn.microsoft.com/en-us/cli/azure/microsoft-graph-migration#graph-command-fails-with-aadsts50005-or-aadsts53000, that is, Microsoft tenant (72f988bf-86f1-41af-91ab-2d7cd011db47) doesn't allow using device code flow to access Microsoft Graph.There is a feature request #22776 to show the signed in account's object ID, but that feature request was suspended due to several unsettled security discussions. You may follow #22776 (comment) to retrieve the object ID from the access token.
Thank you @jiasli for the workaround. Do you have a similar to az ad sp list?
You may use the same approach to get the object ID for a service principal. If this is not what you want, what information do you want to extract from az ad sp list?
@jiasli The approach works for my own object ID because I can az login as myself. But I cannot az login as other objects, such as a service principal for a workspace named 'gcrllama2ws'. I cannot get access token tied to gcrllama2ws and thus cannot apply the same approach to extract object ID of gcrllama2ws from access token. Am I correct?
I cannot get access token tied to gcrllama2ws
Why can't? Is there any error when running az account get-access-token?
@jiasli az account get-access-token only return ID for the current user who logged in with az login. It does not return ID for other entities. So there is no error when running az account get-token-token. But you can only get ID for yourself, not any service principal entity such as 'gcrllama2ws'.
I cannot
az loginas other objects, such as a service principal for a workspace named 'gcrllama2ws'.
What is the relationship between the login service principal and gcrllama2ws?
If gcrllama2ws is different from the login service principal, you need to assign Application.Read.All permission to the login service principal in order to run az ad sp list. This is the designed behavior of Microsoft Graph.
I am not sure if I understand the question "What is the relationship between the login service principal and gcrllama2ws?". What I am trying to do is:
az loginwith my SC-Alt account, e.g. [email protected]az ad sp list --display-name gcrllama2wswhich is blocked by AADSTS70043
So I guess the "login service principal" is my extra ID, not really a service principal, and not an app either. I am not sure if I could assign my extra ID the role of "Application.Read.All". But that's an interesting idea.