AZ-104 Deploy and Manage Azure Compute Practice Question
You need to deploy a new Ubuntu VM that automatically creates an app user and installs packages the first time it boots. Which approach should you use?
⚠ Common exam trap
Watch out — candidates often confuse Azure Policy (a governance tool) with a configuration management tool like cloud-init or Desired State Configuration (DSC), assuming Policy can execute scripts inside a VM when it only enforces resource-level rules.
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
✓
Use cloud-init in the VM creation settings to perform first-boot configuration.
B is correct because cloud-init is the standard, native mechanism for performing first-boot configuration on Linux VMs in Azure. It allows you to inject a configuration file (e.g., YAML or shell script) during VM creation that automatically creates users, installs packages, and runs custom commands on the first boot, without requiring any post-deployment scripts or manual intervention.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use an availability set so the VM runs the initialization tasks during host placement.
Why it's wrong here
An availability set is a logical grouping of VMs that spreads them across fault domains and update domains to guarantee higher availability during planned and unplanned maintenance. The Azure Fabric placement process decides where the VM runs, but it has no capability to execute guest OS scripts or perform initial configuration. Availability sets solely improve resilience; they cannot create an app user or install packages on the VM.
When this WOULD be correct
When the question asks how to ensure high availability for a multi-VM application by placing VMs in separate fault and update domains to minimize downtime during maintenance or failures.
- ✓
Use cloud-init in the VM creation settings to perform first-boot configuration.
Why this is correct
Cloud-init is the standard Linux initialization method for automating first boot tasks. It can create users, install packages, write files, and run commands as the VM starts. This makes it a good fit when you want the operating system to configure itself without needing to sign in afterward or run a separate manual script.
- ✗
Use an Azure Policy assignment to install the packages after deployment.
Why it's wrong here
Azure Policy is a governance and compliance service that evaluates Azure resources against rules and can enforce tags, locations, or security settings. It does not execute scripts or commands inside a VM's guest operating system, so it cannot install Linux packages or create an app user as part of first-boot configuration. While policy can trigger remediation tasks for Azure resources, it lacks the ability to run OS-level initialization logic like cloud-init.
When this WOULD be correct
If the question asked how to enforce that all deployed VMs in a subscription have a specific security package installed, an Azure Policy assignment with a DeployIfNotExists effect could trigger a remediation task to install the package after deployment.
- ✗
Use a managed disk snapshot and attach it to the VM after deployment.
Why it's wrong here
A managed disk snapshot captures a point-in-time copy of a disk for backup or to create a new disk from that copy. Attaching it to a new VM simply reuses that image; it does not trigger any provisioning or initialization tasks, nor does it define a user during the VM's first boot. Snapshots are useful for cloning or recovery, but they are not a mechanism for automating OS setup or package installation.
When this WOULD be correct
When the question asks to deploy multiple VMs from a pre-configured image that already has the app user and packages installed, using a snapshot to create a managed disk and attach it to new VMs would be correct for rapid, consistent deployment.
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.
✓Use cloud-init in the VM creation settings to perform first-boot configuration.Correct answer▾
Why this is correct
Cloud-init is the standard Linux initialization method for automating first boot tasks. It can create users, install packages, write files, and run commands as the VM starts. This makes it a good fit when you want the operating system to configure itself without needing to sign in afterward or run a separate manual script.
✗Use an availability set so the VM runs the initialization tasks during host placement.Wrong answer — click to see why▾
Why this is wrong here
An availability set is used for high availability by distributing VMs across fault domains, not for executing initialization tasks like creating users or installing packages.
★ When this WOULD be the correct answer
When the question asks how to ensure high availability for a multi-VM application by placing VMs in separate fault and update domains to minimize downtime during maintenance or failures.
Why candidates choose this
Candidates may confuse availability sets with custom scripts or extensions that run during deployment, mistakenly thinking the placement process triggers initialization tasks.
✗Use an Azure Policy assignment to install the packages after deployment.Wrong answer — click to see why▾
Why this is wrong here
Azure Policy is used to enforce compliance rules across resources, not to execute first-boot configuration scripts or install packages on a VM. It cannot run commands inside a VM after deployment.
★ When this WOULD be the correct answer
If the question asked how to enforce that all deployed VMs in a subscription have a specific security package installed, an Azure Policy assignment with a DeployIfNotExists effect could trigger a remediation task to install the package after deployment.
Why candidates choose this
Candidates may confuse Azure Policy with Azure Automation or Custom Script Extension, thinking policy can execute scripts, or they may overestimate the scope of policy's capabilities to include post-deployment configuration.
✗Use a managed disk snapshot and attach it to the VM after deployment.Wrong answer — click to see why▾
Why this is wrong here
A managed disk snapshot captures the disk state at a point in time but does not execute first-boot configuration tasks like creating users or installing packages; it simply clones the disk content.
★ When this WOULD be the correct answer
When the question asks to deploy multiple VMs from a pre-configured image that already has the app user and packages installed, using a snapshot to create a managed disk and attach it to new VMs would be correct for rapid, consistent deployment.
Why candidates choose this
Candidates may confuse snapshots with generalized images, thinking a snapshot can include initialization scripts, or they may believe attaching a snapshot disk triggers setup tasks similar to a custom image.
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
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.