AZ-400 ยท Identity, access and permissions
Service principal vs managed identity
Microsoft Entra service principals, system-assigned and user-assigned managed identities, secret/certificate lifecycle, which to use for a given workload and hosting location.
Key points
- Both are workload identities in Microsoft Entra ID.
- Managed identity: attached to Azure compute; you never see or rotate its credential.
- System-assigned: one per resource, deleted with it.
- User-assigned: standalone resource, shareable, deleted explicitly.
- Service principal (app registration): works anywhere; you own its secret or certificate, or use a federated credential to avoid secrets.
Source: https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview
Practice questions
Which type of managed identity is deleted automatically when its parent Azure resource is deleted?
- System-assigned managed identity
- User-assigned managed identity
- Service principal with a client secret
- Service principal with a certificate
Show answer
Answer: A. System-assigned managed identity
A system-assigned identity shares the lifecycle of its resource. A user-assigned identity is a separate resource and must be deleted explicitly.
Which statements about user-assigned managed identities are true?
- They are created as a standalone Azure resource
- The same identity can be associated with more than one resource
- They are deleted automatically when a VM using them is deleted
- They have an independent lifecycle and must be deleted explicitly
- You must rotate their client secret every year
Show answer
Answer: A. They are created as a standalone Azure resource, B. The same identity can be associated with more than one resource, D. They have an independent lifecycle and must be deleted explicitly
They are standalone resources with their own lifecycle and can be attached to many resources. Being tied to a single resource and deletion with the VM describe the system-assigned type; and you never handle the credential of either type.
An application that uses a managed identity on an Azure VM must still keep a client secret in its configuration to obtain tokens.
Show answer
Answer: False
False. The code asks Microsoft Entra ID for a token through MSAL or Azure.Identity and is authenticated by the environment it runs in. No secret is stored.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
