Managed Identity
A managed identity is an automatically managed Microsoft Entra ID identity attached to an Azure resource such as a VM or App Service. It lets the resource authenticate to other Azure services with no stored credentials.
Managed Identity
The platform creates the identity, issues short-lived tokens, and rotates the credentials, so no client secret exists for you to store, leak, or rotate. Your code requests a token from a local endpoint and presents it to the target service. You then grant the identity access with a normal Azure RBAC role assignment.
System-Assigned or User-Assigned?
- System-assigned: Tied to one resource and deleted with it. Simplest for a single VM or app.
- User-assigned: A standalone resource you attach to several resources. Better when many apps share the same permissions or you want the identity to outlive any one resource.
How Do You Use One?
az webapp identity assign --name mumbai-api --resource-group mumbai-prod-rg az role assignment create \ --assignee <managed-identity-principal-id> \ --role "Key Vault Secrets User" \ --scope $(az keyvault show --name mumbai-prod-kv --query id -o tsv)Why It Matters in Production
A fintech like CRED can have its API read database secrets from Key Vault using a managed identity, so no password sits in config or a pipeline variable.
TipPrefer user-assigned identities when you deploy infrastructure and role assignments before the resource exists, because the identity ID is known up front.
Common MistakeUsing a system-assigned identity, deleting and recreating the resource, then wondering why access broke. The new resource gets a new identity and needs fresh role assignments.
Frequently Asked Questions
How is a managed identity different from a service principal with a secret?
A service principal needs a secret or certificate you must store and rotate. A managed identity has no credential for you to handle, because Azure manages it.
Can I use a managed identity outside Azure?
No. Managed identities work only for resources running in Azure. External workloads should use workload identity federation instead.
Does a managed identity have permissions by default?
No. It starts with no access, and you must assign RBAC roles at the narrowest scope it needs.