A virtual machine hosts one application whose entire purpose is to read messages from a single Azure Storage queue, and the identity team wants the workload's identity to be removed automatically when that virtual machine is deleted, leaving no orphaned identity object to clean up. Which managed identity configuration meets this lifecycle requirement?
- AA user-assigned managed identity attached to the virtual machine, retained so it can be reused by future resources.
- BA service principal created manually in Microsoft Entra ID and assigned to the virtual machine for the duration of its life.
- CA system-assigned managed identity enabled on the virtual machine, which Azure deletes automatically when the virtual machine is deleted. Correct
- DAn app registration with a client secret deployed to the virtual machine and deleted by a teardown script when the VM is removed.
Why A is wrong: A user-assigned identity is tempting because it is also credential-free, but its lifecycle is independent of the virtual machine, so it survives deletion and becomes the orphaned object the team wants to avoid.
Why B is wrong: A manually created service principal is plausible, but it has no automatic lifecycle binding to the virtual machine, so deleting the VM leaves the service principal behind to be cleaned up by hand.
Why C is correct: A system-assigned managed identity is tied directly to the lifecycle of its host resource, so Azure deletes the identity automatically when the virtual machine is deleted, leaving no orphaned object.
Why D is wrong: An app registration with a teardown script could be made to clean up, but it relies on a stored secret and a fragile manual script rather than the platform deleting the identity automatically.