AZ-104 Manage Azure Identities and Governance Practice Question
Two Azure virtual machines run the same automation script and both need access to Key Vault and Storage. The script must keep working if one VM is redeployed, and the team wants the same identity to be usable by both VMs. What should the administrator use?
⚠ Common exam trap
Many exam-takers assume a system-assigned managed identity can be shared across VMs because it is 'managed,' but they overlook that it is inherently tied to a single resource's lifecycle and cannot be assigned to multiple resources.
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 both VMs
A user-assigned managed identity is the correct choice because it is created as a standalone Azure resource and can be assigned to multiple VMs. This ensures both VMs share the same identity for accessing Key Vault and Storage, and the identity persists independently of any single VM's lifecycle, so redeploying one VM does not break access for the other.
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 managed identity is tied directly to a single virtual machine; each VM receives its own unique identity, and it is deleted when the VM is deleted. If both VMs run the same script, they would need separate role assignments in Key Vault, and the script would not use a common identity. This makes it unsuitable for a scenario requiring a shared identity across multiple VMs, and it creates additional management overhead.
When this WOULD be correct
A system-assigned managed identity would be correct if the question required each VM to have its own unique identity and the script only needed access from that specific VM, with no requirement for identity sharing or persistence across redeployments.
- ✓
A user-assigned managed identity attached to both VMs
Why this is correct
A user-assigned managed identity is created as an independent Azure AD identity and can be assigned to multiple Azure resources, including both virtual machines. Because its lifecycle is decoupled from the VMs, it survives VM deletion or redeployment, and both VMs can share the same identity to authenticate to Azure Key Vault without storing credentials. This allows the automation script to use the same identity for role-based access control, making it the correct and most secure choice.
- ✗
A service principal stored in a configuration file on the VMs
Why it's wrong here
While a service principal could theoretically be shared, storing its client secret or certificate in a configuration file on each VM exposes credentials to the host, increasing the risk of theft or accidental exposure. This approach also requires manual secret rotation and management, and the script must handle the secret securely at runtime. Managed identities eliminate these secrets entirely, so this option is less secure and not the recommended pattern for Azure resources.
When this WOULD be correct
If the question required using a specific Azure AD application identity for external integrations (e.g., with a third-party SaaS) and the VMs were not in Azure (e.g., on-premises), a service principal with certificate stored in a configuration file would be appropriate.
- ✗
A storage account access key stored in the script
Why it's wrong here
A storage account access key is a long-lived secret that grants full access to the storage account, not to Azure Key Vault. The script would need separate authentication to Key Vault, such as a client secret or managed identity, to retrieve secrets. Storing the access key directly in the script is a security anti-pattern: it exposes the key in source code, logs, or configuration, and it does not solve the identity requirement.
When this WOULD be correct
This option would be correct if the question asked for a simple, low-security method to allow a script running on a single VM to access a storage account without using Azure AD or managed identities, and the script is not shared across VMs.
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 both VMsCorrect answer▾
Why this is correct
A user-assigned managed identity is created as an independent Azure AD identity and can be assigned to multiple Azure resources, including both virtual machines. Because its lifecycle is decoupled from the VMs, it survives VM deletion or redeployment, and both VMs can share the same identity to authenticate to Azure Key Vault without storing credentials. This allows the automation script to use the same identity for role-based access control, making it the correct and most secure choice.
✗A system-assigned managed identity on each VMWrong answer — click to see why▾
Why this is wrong here
A system-assigned managed identity is tied to a single VM and cannot be shared across VMs. If one VM is redeployed, its identity is lost, and the script on the other VM cannot use the same identity.
★ When this WOULD be the correct answer
A system-assigned managed identity would be correct if the question required each VM to have its own unique identity and the script only needed access from that specific VM, with no requirement for identity sharing or persistence across redeployments.
Why candidates choose this
Candidates may confuse system-assigned and user-assigned managed identities, assuming both can be shared, or they may think that each VM having its own identity is sufficient for the scenario.
✗A service principal stored in a configuration file on the VMsWrong answer — click to see why▾
Why this is wrong here
A service principal stored in a configuration file on the VMs does not provide automatic credential rotation and would break if the file is lost or the VM is redeployed, failing the requirement for a consistent identity across redeployments.
★ When this WOULD be the correct answer
If the question required using a specific Azure AD application identity for external integrations (e.g., with a third-party SaaS) and the VMs were not in Azure (e.g., on-premises), a service principal with certificate stored in a configuration file would be appropriate.
Why candidates choose this
Candidates may think a service principal is the standard way to grant permissions to Azure resources, overlooking that managed identities are the recommended approach for Azure VMs to avoid managing credentials.
✗A storage account access key stored in the scriptWrong answer — click to see why▾
Why this is wrong here
A storage account access key stored in the script is not an identity; it's a static credential that doesn't support the requirement for a single identity usable by both VMs. If one VM is redeployed, the key remains valid, but it doesn't provide a unified identity and poses security risks if exposed in scripts.
★ When this WOULD be the correct answer
This option would be correct if the question asked for a simple, low-security method to allow a script running on a single VM to access a storage account without using Azure AD or managed identities, and the script is not shared across VMs.
Why candidates choose this
Candidates might think storing an access key in the script is an easy way to grant access without understanding that it's not an identity, doesn't support multiple VMs with the same identity, and violates security best practices.
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
Privileged Identity Management (PIM)
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
User-assigned managed identity
A user-assigned managed identity is a standalone Azure identity that can be assigned to one or more Azure resources, enabling them to authenticate to other services without storing credentials.
About these practice questions
This AZ-104 question is part of Courseiva's 1,049-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.