Lesson308 words

Service principals and managed identities

Choose between service principals and managed identities

An app registration creates an application object plus a tenant-local service principal. Each managed identity also creates a special service principal. The practical differences are credential ownership, caller location, lifecycle, and application capabilities.

App registration and tenant service principalManaged identity
CredentialClient secret, certificate, or federated credentialManaged by Azure — none for you to store
Direct useApplication authenticates with its configured credentialThe owning supported Azure resource obtains tokens; a user-assigned identity can also be a configured federation target
LifecycleIndependent of any resourceTied to the resource (system-assigned) or standalone (user-assigned)

System-assigned versus user-assigned

System-assignedUser-assigned
LifecycleCreated with the resource, deleted with itStandalone; survives resource deletion
SharingOne resource onlyShared across many resources
Use whenA single resource needs its own identitySeveral resources need the same role assignments

Deleting a resource removes its system-assigned service principal, but Azure RBAC role-assignment records are not automatically deleted with either managed-identity type. Clean up stale assignments separately.

Choosing the identity

For eligible Azure-hosted code, prefer managed identity when the app does not need user sign-in, to act as a web API, or multitenant operation. Azure manages its credential, but you still grant only the permissions it needs.

An external OIDC-capable workload does not force an app-registration service principal. Microsoft Entra workload identity federation can trust the external provider through either a user-assigned managed identity or an app registration, without a stored Entra secret. A system-assigned identity remains directly usable only by its owning Azure resource.

Primary sources

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free