Workload identity: system-assigned vs user-assigned managed identity vs service principal vs federation

Verdict: Managed identity removes stored credentials entirely; use system-assigned for a single non-shared resource, user-assigned when several resources must share one identity lifecycle, and workload identity federation for external or cross-cloud workloads. Never store a client secret.

CriterionSystem-assigned managed identityUser-assigned managed identityService principal with client secretWorkload identity federation
LifecycleCreated and deleted with its single parent resourceIndependent lifecycle; attach to multiple resourcesIndependent of any resource; manually managedIndependent; trust relationship, not a stored identity
Stored secretNoneNoneClient secret stored in app settings or configNone; external token exchanged for short-lived Entra token
Best fitSingle, non-shared workload (one App Service instance)Fleet of resources sharing one identity, e.g. five Function appsAvoid; replace with a managed identityExternal or other-cloud workload calling an Entra-secured API
External or cross-cloud useNot usable outside AzureNot usable outside AzureUsable but leaves a long-lived credential outside AzureExchanges the external platform's own token; no long-lived Azure credential stored outside Azure
Least privilegeScope RBAC narrowly to the specific resources neededScope RBAC narrowly; grant once, applies to all attached resourcesRisk of over-broad grants (e.g. Owner) for convenienceDedicated least-privilege identity, reviewed periodically

Rules

Traps