Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

Can I call 'az ad user list' using the Graph Beta? #22636

Open pmatthews05 opened 2 years ago

pmatthews05 commented 2 years ago

Describe the bug

When using az ad user list in the new version of AZ CLI 2.37.0, the result that comes back is the graph call https://graph.microsoft.com/v1.0/users

I would like to know if you can tell the az cli to use the Beta version of the MS Graph calls? https://graph.microsoft.com/beta/users

Command Name az ad user list

Environment Summary

Windows-10-10.0.17763-SP0
Python 3.10.4
Installer: MSI

azure-cli 2.37.0

Extensions:
account 0.2.2
application-insights 0.1.15
azure-devops 0.23.0
costmanagement 0.1.1
log-analytics 0.2.2
logic 0.1.5

Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1

Additional Context

yonzhan commented 2 years ago

@jiasli for awareness

pmatthews05 commented 2 years ago

For context, with the BETA graph calls there is so much more information you can grab about the user when using the beta. Originally in my code I called az ad user and queried/filtered on userType=Member. This ensured I didn't bring back any Guest users. Or the reverse userType=Guest.

With the latest cli, due to using MS Graph and V1.0 this property isn't available, only with beta.

Having a config, or switch to decide if you are calling the v1.0 or beta would be useful in general for any of the MS Graph calls.

jiasli commented 2 years ago

Azure CLI currently doesn't have native support for beta API. We will consider this as a feature request.

pmatthews05 commented 2 years ago

Thanks @jiasli for the confirmation. With the recent swap from Windows Graph to Microsoft Graph, the lack of these properties will require this feature.

I can see two useful places to put the beta switch.

  1. On the command you are calling, allowing just that call to use the beta.
  2. Within the az config section making all call use the beta.

Alternative for now is just calling az rest --method get -url https://graph.microsoft.com/beta/users

However, I'm having a problem getting the next link to work. I've obtained the odata.nextLink, however, when trying to put that url in the next az rest url, because of the $ symbol in the next link, it fails to call it. Do you happen to know how I can escape the url correctly? I know that the escape character is ` but I haven't found a working valid way to escape the $ characters.