What Is a Service Principal? Give Apps and Automation Their Own Identity
A Microsoft Entra ID service principal is an application’s security identity in a particular directory (tenant), used to authenticate and receive permissions for resources. If an app registration (application object) is the shared blueprint for an app, the service principal is its tenant-specific instance; the permissions on that instance determine what the app can do there. A service principal is not itself a password or certificate: the workload authenticates with separate credentials or a managed identity.
This article focuses on application service principals in Microsoft Entra ID. Azure managed identities also use service principal objects, but credential handling differs. Similar terms in AWS IAM roles or Google Cloud service accounts do not mean the underlying object models are identical.
How are an app registration and a service principal related?
A registered Microsoft Entra app generally involves two objects. The application object, created through app registration, holds shared configuration such as the app name, supported account types, authentication settings, redirect URIs, and credentials. A service principal represents the app in a particular tenant and controls who in that organization can use it and which resources it can access. The app’s definition and its permission-bearing instance in an organization are related, but they are different directory objects.
A single-tenant app is generally used in the tenant where it was registered. A multitenant app has an application object in the developer’s tenant; when another organization consents to use it, a service principal for that app is also created in the organization’s tenant. Administrators in each organization control the permissions and use of that local service principal. Consent in one tenant does not automatically grant the app permissions in another.
For an app service principal, two identifiers often matter: the client ID (application ID) and the object ID. The client ID identifies the app registration and can refer to the same app across tenants. The object ID identifies a particular service principal in one tenant, so role assignments and directory operations often need the object ID from the target tenant. Confusing them can make the intended app hard to locate or lead to assigning access to the wrong object.
How does a service principal receive permissions?
A service principal is an identity; actual access requires both authentication and authorization. An automation workload usually supplies a tenant ID and client ID, then proves the app’s identity with a client secret, certificate, or federated credential to obtain an access token. The target API validates the token and allows the request according to its configured permissions or roles. Having a credential does not automatically grant data access, and configuring permissions alone does not let the app authenticate.
Permissions depend on the target resource. Delegated permissions for an API such as Microsoft Graph operate on behalf of a signed-in user. Application permissions grant the app its own access for background work where no user is signed in; they can reach organization-wide data, so they require administrator consent. For Azure resources, Azure RBAC roles can be assigned to a service principal at a subscription, resource group, or individual resource scope. API consent and Azure RBAC are separate authorization systems: configuring one does not grant the other’s permissions.
Hypothetical example: Suppose a company’s nightly reporting job reads files in a report folder through a document-storage API. An administrator registers the app, confirms that a service principal exists in the tenant where the automation runs, requests only the API’s read-only application permission, and obtains the required administrator consent. The job uses a certificate or federation to get a token rather than embedding a secret in code. The team checks the target API’s logs for the app’s requests and access scope. This example illustrates the permission flow; it was not configured or tested in a live tenant.
How does a managed identity differ from a service principal?
A managed identity gives an Azure resource an automatically managed identity in Entra ID, so it can authenticate without storing credentials in code. In the directory, a managed identity is represented by a service principal, but it does not have an application object like a regular app registration. Azure manages its credentials, reducing the need for people to create, store, and rotate a password or certificate. The managed identity still needs data permissions or an RBAC role on the target service.
If code runs on an Azure resource that supports managed identities and needs to reach a compatible service, consider managed identity first. For external CI/CD jobs, servers outside Azure, or OAuth integrations based on app registrations, a service principal can use a certificate or federated credential. A client secret is a fallback when compatibility requires it, but it must be protected, expired, and rotated; never put it in source code, repositories, or logs. These are not simply “good” and “bad” alternatives: the right choice depends on where the workload runs and who manages its credentials.
What should you check to create and operate one safely?
**Record purpose and owner:** Document one application or automation purpose, an accountable owner, target resources, required permissions, and an end date for each service principal. Avoid sharing one identity across unrelated jobs.
**Choose an identity for the runtime:** Prefer managed identity when a supported Azure resource can use it. For external or cross-environment workloads, consider federation or certificates; use secrets only when necessary and for a limited period.
**Grant least privilege:** Assign only the required API permissions or the narrowest Azure RBAC scope and role. Before approving application permissions or admin consent, review organization-wide impact, data access, and revocation procedures.
**Protect credentials:** Keep credentials out of source code and ordinary configuration, and restrict access to their storage. Track expiration, define certificate/secret rotation and recovery procedures, and narrowly constrain the trusted issuer, audience, and subject for federation.
**Monitor and review:** Check Entra sign-in and audit logs for the identity, failures, unusual times or locations, and permission changes. Have the owner periodically recertify the purpose and actual access, and remove unused permissions and credentials.
**Plan retirement:** Identify dependent jobs and resource owners first. Disabling the identity can cause token issuance and API calls to fail. Where appropriate, disable it for a verification period, then delete the service principal and credentials after confirming no impact.
A service principal gives an application its own identity and bounded permissions instead of borrowing a person’s account for automation. But broad permissions or leaked credentials can let automation continue acting without a person. First check whether the runtime can use managed identity; when creating a service principal, plan least privilege, secure authentication, ownership, logging, and a review and cleanup schedule together.
References
[Applications and service principals in Microsoft Entra ID](https://learn.microsoft.com/en-us/graph/applications-concept-overview)
[Application model in the Microsoft identity platform](https://learn.microsoft.com/en-us/entra/identity-platform/application-model)
[Govern service accounts in Microsoft Entra](https://learn.microsoft.com/en-us/entra/architecture/govern-service-accounts)
[Register an app and create a service principal](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal)
[Permissions and consent in the Microsoft identity platform](https://learn.microsoft.com/en-us/entra/identity-platform/consent-types-developer)
[Managed identities for Azure resources overview](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)
[Managed identities FAQ: directory objects and service principals](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/managed-identities-faq)
[Add and manage app credentials in Microsoft Entra](https://learn.microsoft.com/en-us/entra/identity-platform/how-to-add-credentials)