This cheatsheet is aimed at DevOps professionals using Azure AD. It covers commands for creating, managing, and troubleshooting service principals and their role assignments.
az ad sp create-for-rbac --name <appName> --role Contributor --scopes /subscriptions/<subscriptionId>
az ad sp list --filter "displayName eq '<appName>'" --output table
az ad sp show --id <servicePrincipalId>
az ad sp delete --id <servicePrincipalId>
az ad sp credential reset --name <appName> --credential-description "NewCred" --end-date "2025-01-01"
az role assignment list --assignee <servicePrincipalId> --output table
az role assignment create --assignee <servicePrincipalId> --role Reader --scope /subscriptions/<subscriptionId>
az role assignment delete --assignee <servicePrincipalId> --role Reader --scope /subscriptions/<subscriptionId>
az login --service-principal --username <appId> --password <passwordOrCert> --tenant <tenantId>
az role assignment list --assignee <servicePrincipalId> --query "[].{Role:roleDefinitionName, Scope:scope}" --output table