User-Assigned Managed Identity: Survive VM Deletion and Recreation
Exhibit
Identity requirement: - VM1 in rg-web - VM2 in rg-api - VM3 in rg-batch - All three VMs need the same access to an Azure service - The identity must not disappear when any one VM is deleted
Based on the exhibit, three VMs in different resource groups must use the same Azure identity, and the identity must continue working if one VM is deleted and recreated. What should you use?
Quick Answer
The answer is a user-assigned managed identity, because it is an independent Azure resource that persists separately from any VM. Unlike a system-assigned identity, which is tied to a single VM’s lifecycle and is destroyed when the VM is deleted, a user-assigned managed identity can be created once and attached to multiple VMs across different resource groups. If one VM is deleted and recreated, the identity remains intact and can simply be reassigned to the new VM, ensuring continuous access to Azure resources. On the AZ-104 exam, this scenario tests your understanding of identity lifecycle management and the key distinction between identity types—a common trap is choosing system-assigned for simplicity, but that fails when VMs are recreated. Remember the memory tip: “User-assigned survives the recycle bin; system-assigned goes down with the ship.”
⚠ Common exam trap
It's easy for candidates to confuse system-assigned managed identities (which are tied to VM lifecycle) with user-assigned managed identities (which are independent resources), leading them to choose Option A despite the requirement for identity persistence across VM deletion and recreation.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
A user-assigned managed identity attached to all three VMs.
A user-assigned managed identity is an Azure resource that can be created independently and then assigned to multiple VMs. Because it persists as a separate resource in Azure, deleting and recreating a VM does not affect the identity; you simply reattach the same user-assigned identity to the new VM. This ensures the identity continues working across VM lifecycle changes, meeting the requirement for a shared, resilient identity.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A system-assigned managed identity on each VM.
Why it's wrong here
A system-assigned identity is tied to one specific VM, so it does not meet the requirement for one shared identity across multiple VMs.
When this WOULD be correct
A system-assigned managed identity would be correct if each VM needed its own unique identity (e.g., for individual resource access) and the question did not require the identity to survive VM deletion and recreation.
- ✓
A user-assigned managed identity attached to all three VMs.
Why this is correct
A user-assigned managed identity is correct because it is created independently from any single VM and can be attached to multiple resources. That makes it ideal when several VMs need the same identity and the identity must remain available even if one VM is deleted and recreated.
- ✗
A service principal stored in the VM image.
Why it's wrong here
A service principal stored in an image introduces secret management problems and does not provide the clean Azure-managed identity model described in the scenario.
When this WOULD be correct
This option would be correct if the question asked for a solution to authenticate an application running on a VM to Azure resources using a fixed identity that is embedded in the VM image, and the VMs are never deleted or recreated (e.g., for a static set of VMs using a custom image with pre-configured credentials).
- ✗
A shared access signature assigned to the resource group.
Why it's wrong here
A SAS token is not an identity and cannot be attached to VMs as a reusable Azure login mechanism.
When this WOULD be correct
A question where you need to grant time-limited, delegated access to a specific storage container or blob for a client application, without sharing the storage account key. For example, 'You need to allow a third-party app to read blobs from a container for 24 hours. What should you use?'
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The AZ-104 exam frequently reuses these exact scenarios with slightly different constraints.
✓A user-assigned managed identity attached to all three VMs.Correct answer▾
Why this is correct
A user-assigned managed identity is correct because it is created independently from any single VM and can be attached to multiple resources. That makes it ideal when several VMs need the same identity and the identity must remain available even if one VM is deleted and recreated.
✗A system-assigned managed identity on each VM.Wrong answer — click to see why▾
Why this is wrong here
A system-assigned managed identity is tied to the lifecycle of each VM; if a VM is deleted and recreated, it gets a new identity, breaking the requirement that the same identity must persist across deletion and recreation.
★ When this WOULD be the correct answer
A system-assigned managed identity would be correct if each VM needed its own unique identity (e.g., for individual resource access) and the question did not require the identity to survive VM deletion and recreation.
Why candidates choose this
Candidates may think system-assigned identities are simpler to set up and assume they can be shared, overlooking that they are per-resource and not persistent across deletion.
✗A service principal stored in the VM image.Wrong answer — click to see why▾
Why this is wrong here
A service principal stored in the VM image would be tied to that specific image and would not persist if a VM is deleted and recreated, as the new VM would need to have the same image or the service principal manually re-configured. It also cannot be shared across multiple VMs in different resource groups without additional configuration.
★ When this WOULD be the correct answer
This option would be correct if the question asked for a solution to authenticate an application running on a VM to Azure resources using a fixed identity that is embedded in the VM image, and the VMs are never deleted or recreated (e.g., for a static set of VMs using a custom image with pre-configured credentials).
Why candidates choose this
Candidates may think a service principal stored in the image provides a persistent identity that survives VM recreation, but they overlook that the identity is tied to the image, not the VM resource, and that managed identities are the proper Azure feature for this scenario.
✗A shared access signature assigned to the resource group.Wrong answer — click to see why▾
Why this is wrong here
A shared access signature (SAS) is used to delegate access to Azure Storage resources, not to provide an Azure identity for VMs. It cannot be assigned to a resource group and does not persist across VM deletion and recreation.
★ When this WOULD be the correct answer
A question where you need to grant time-limited, delegated access to a specific storage container or blob for a client application, without sharing the storage account key. For example, 'You need to allow a third-party app to read blobs from a container for 24 hours. What should you use?'
Why candidates choose this
Candidates may confuse SAS with managed identities because both are used for authentication and authorization in Azure, or they might think SAS can be applied broadly to resource groups for identity purposes.
Analysis generated from the official AZ-104blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
Go deeper
Related to this question
Learn chapter
Dynamic Membership Groups
Key term
Azure resource
An Azure resource is a manageable item available through Microsoft Azure, such as a virtual machine, database, or web app.
Key term
Managed identity
A managed identity is an automatically managed service principal in Azure that allows your code to authenticate to any service that supports Azure AD authentication without storing credentials.
About these practice questions
One of 1,049 original AZ-104 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on AZ-104
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A bootstrap script must install software on three VMs, then download configuration files from Blob Storage. Security forbids secrets in templates or scripts, and the same authentication method must work after the VMs are rebuilt. Which two choices should you make? Select two.
hard- ✓ A.Assign a user-assigned managed identity and attach it to each VM.
- B.Store the storage account access key in a script variable.
- ✓ C.Use a Custom Script Extension to run the bootstrap commands at provisioning.
- D.Create a separate local administrator account for the script to use.
- E.Embed a SAS token directly in the Bicep parameters file.
Why A: A user-assigned managed identity provides a secure, credential-free authentication method that persists across VM rebuilds. Unlike system-assigned managed identities, which are tied to a specific VM lifecycle and are lost when the VM is deleted, a user-assigned identity is a standalone Azure resource that can be reassigned to new VMs. This allows the bootstrap script to authenticate to Azure Blob Storage via Azure AD without storing any secrets, satisfying the security constraint. A Custom Script Extension is the appropriate Azure mechanism to run the bootstrap script during provisioning, and it can use the VM's managed identity to download the configuration files from Blob Storage.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-104 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-104 exam.