Service Principal
A service principal is a non-human identity in a Microsoft Entra ID tenant that applications, pipelines, and scripts use to authenticate to Azure. It receives its own RBAC permissions, separate from any employee account.
Service Principal
A service principal is the tenant-local instance of an app registration. The app registration defines the application globally, and the service principal is what actually gets role assignments on subscriptions and resource groups. Using one for automation avoids tying a pipeline to a person's account, which breaks on password resets, MFA prompts, and offboarding.
How Does a Service Principal Authenticate?
It can use a client secret, a certificate, or a federated credential. Federated credentials (workload identity federation) let GitHub Actions or Azure DevOps exchange a short-lived OIDC token for Azure access, so no secret is stored at all.
How Do You Create One With Limited Scope?
az ad sp create-for-rbac --name cicd-orders-sp \ --role Contributor \ --scopes /subscriptions/<sub-id>/resourceGroups/mumbai-orders-prod-rgWhy It Matters in Production
A fintech like CRED can scope its pipeline's service principal to only the resource groups it deploys to, so a leaked credential cannot reach unrelated production data.
SecurityPrefer managed identities when the workload runs in Azure, and workload identity federation for external CI systems. Both remove the secret you would otherwise have to protect.
Common MistakeGiving a pipeline a long-lived secret stored as a plain variable. Secrets get logged or forgotten, then expire and break deployments at a bad moment.
Frequently Asked Questions
What is the difference between an app registration and a service principal?
The app registration is the global definition of the application, and the service principal is its local identity in a tenant. Role assignments attach to the service principal.
Service principal or managed identity?
Use a managed identity for resources running in Azure, since Azure handles its credentials. Use a service principal for external systems such as CI pipelines, ideally with federated credentials.
How do I rotate a service principal secret?
Create a new secret or certificate, update every consumer, then remove the old one. Secrets have an expiry, so track it to avoid surprise outages.