Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure CLI is migrated to Microsoft Graph in 2.37.0 #22580

Closed
jiasli opened this issue May 24, 2022 · 3 comments
Closed

Azure CLI is migrated to Microsoft Graph in 2.37.0 #22580

jiasli opened this issue May 24, 2022 · 3 comments
Assignees
Labels
Milestone

Comments

@jiasli
Copy link
Member

jiasli commented May 24, 2022

Due to the deprecation of Azure Active Directory (Azure AD) Graph, Azure CLI is migrated to Microsoft Graph in 2.37.0 which is released on 2022-05-24.

Please carefully review all breaking changes introduced during this migration: https://docs.microsoft.com/cli/azure/microsoft-graph-migration

If you are not ready for the migration yet, such as lacking Microsoft Graph permissions, you may keep using Azure CLI versions <= 2.36.0. If you have already installed 2.37.0, you may roll back to a previous version following the "Install specific version" section under the installation documents (except for Homebrew which doesn't support installing previous versions): https://docs.microsoft.com/en-us/cli/azure/install-azure-cli

If you have any questions, please create an issue at https://github.com/Azure/azure-cli/issues

References

@ghost ghost added Auto-Assign Auto assign by bot Graph az ad labels May 24, 2022
@ghost ghost assigned jiasli May 24, 2022
@ghost ghost added this to the Backlog milestone May 24, 2022
@jiasli jiasli pinned this issue May 24, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented May 24, 2022

This is a really huge achievement for Azure CLI to migrate to Microsoft Graph in 2.37.0 due to the deprecation of Azure Active Directory (Azure AD) Graph !!

@jiasli
Copy link
Member Author

jiasli commented Jun 9, 2022

Call Microsoft Graph API with az rest

Azure CLI's az ad command group is only designed to facilitate interacting with Azure resources. It is NOT designed to be a fully-fledged client for managing Microsoft Graph. Therefore, only a limited subset of Microsoft Graph API is supported natively by Azure CLI.

For non-supported Microsoft Graph APIs or object properties, you may call APIs directly with az rest to achieve the same effect as az ad commands, including all latest features from Microsoft Graph API. az ad automatically authenticates to Microsoft Graph API.

⚠️ WARNING: Calling API (not limited to Microsoft Graph API) directly with az rest is only a supplemental feature of Azure CLI. It is not guaranteed to work and is subject to change, for reasons including but not limited to Azure CLI permission change, Microsoft Graph service limitation, AAD Conditional Access policies, etc.

ℹ️ NOTE: The First Party App 04b07795-8ddb-461a-bbee-02f9e1bf7b46 of Azure CLI only has following delegated permissions:

  • AuditLog.Read.All
  • Directory.AccessAsUser.All
  • Group.ReadWrite.All
  • User.ReadWrite.All
  • openid

We are on the way of deprecating Directory.AccessAsUser.All and replacing it with Directory.ReadWrite.All. Also see #22775.

Examples

Update redirectUris for an Application

Originally posted at #9501 (comment). We call the Update application API. The GUID part in the following URLs are the object ID of the application.

# Get the application
az rest --method GET --uri 'https://graph.microsoft.com/v1.0/applications/b4e4d2ab-e2cb-45d5-a31a-98eb3f364001'

# Update `redirectUris` for `web` property
az rest --method PATCH --uri 'https://graph.microsoft.com/v1.0/applications/b4e4d2ab-e2cb-45d5-a31a-98eb3f364001' --body '{"web":{"redirectUris":["https://myapp.com"]}}'

Add owners to a service principal

Originally posted at #9250 (comment). We call the servicePrincipal: Add owner API.

appId=93dde3da-9fca-47dd-aee2-409b402ffed3
spObjectId=$(az ad sp show --id $appId --query id --output tsv)

# Get the object Id for the current user
ownerObjectId=$(az ad signed-in-user show --query id -o tsv)

# This applies to both user and service principal as owners
az rest -m POST -u https://graph.microsoft.com/beta/servicePrincipals/$spObjectId/owners/\$ref -b "{\"@odata.id\": \"https://graph.microsoft.com/beta/directoryObjects/$ownerObjectId\"}"

# To add a user as an owner
az rest -m POST -u https://graph.microsoft.com/beta/servicePrincipals/$spObjectId/owners/\$ref -b "{\"@odata.id\": \"https://graph.microsoft.com/beta/users/$ownerObjectId\"}"

# To add a service principal as an owner
az rest -m POST -u https://graph.microsoft.com/beta/servicePrincipals/$spObjectId/owners/\$ref -b "{\"@odata.id\": \"https://graph.microsoft.com/beta/servicePrincipals/$ownerObjectId\"}"

Remarks

@YuanyuanNi YuanyuanNi unpinned this issue Jun 24, 2022
@jsntcy jsntcy pinned this issue Jun 27, 2022
@kairu-ms kairu-ms unpinned this issue Jul 18, 2022
@jiasli jiasli pinned this issue Jul 19, 2022
@yonzhan yonzhan closed this as completed Jul 29, 2022
@jiasli
Copy link
Member Author

jiasli commented Sep 28, 2023

Azure CLI's az ad command group is only designed to facilitate interacting with Azure resources. It is NOT designed to be a fully-fledged client for managing Microsoft Graph. Therefore, only a limited subset of Microsoft Graph API is supported natively by Azure CLI.

See Azure CLI's creator @yugangw-msft's comment #7579 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants