View the service principal of a managed identity using Azure CLI
Managed identities for Azure resources provide Azure services with an automatically managed identity in Azure Active Directory. You can use this identity to authenticate to any service that supports Azure AD authentication without having credentials in your code.
In this article, you learn how to view the service principal of a managed identity using Azure CLI.
If you don't already have an Azure account, sign up for a free account before continuing.
If you're unfamiliar with managed identities for Azure resources, see What are managed identities for Azure resources?.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you are running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For additional sign-in options, see Sign in with the Azure CLI.
When you're prompted, install Azure CLI extensions on first use. For more information about extensions, see Use extensions with the Azure CLI.
View the service principal
This following command demonstrates how to view the service principal of a VM or application with managed identity enabled. Replace
<Azure resource name> with your own values.
az ad sp list --display-name <Azure resource name>
For more information on managing Azure AD service principals using Azure CLI, see az ad sp.