Skip to content

Instantly share code, notes, and snippets.

@clowa
Last active April 26, 2023 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clowa/7f80c05878639ff3eef3a703b7696358 to your computer and use it in GitHub Desktop.
Save clowa/7f80c05878639ff3eef3a703b7696358 to your computer and use it in GitHub Desktop.
How to get the Service Principal ID of an App Registration, even as Guest.

Get Service Principal ID of an App Registration

This procedure relies on the login as the App Registration, therefore you require the following information:

  • Name of the App Registration
  • Tenant ID of the App Registration
  • Client ID of the App Registration
  • Client Secret of the App Registration
  1. Login as the App Registration via Azure CLI
az login --service-principal --tenant "<TENANT_ID>" -u "<CLIENT_ID>"  -p "<CLIENT_SECRET>"
  1. The following command will output the id of the Service Prinicpal of the App Registration. This can be used for example for RBAC assignments.
$ az ad sp list --display-name <App Registration Name> | jq '.[].id'
"d6cf843d-5527-4055-a52e-79a978c45e56"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment