nerdexam
Microsoft

AZ-120 · Question #158

Drag and Drop Question You have an Azure subscription that contains an availability set named AS1 and a virtual machine named VM1. VM1 hosts an SAP NetWeaver application. You need to ensure that AS1…

The correct answer is Set-AzVMOSDisk; Remove-AzVM; New-AzVMConfig; Update-AzAvailabilitySet. Explanation: Adding a VM to an Availability Set in Azure PowerShell Core Concept First You cannot modify the availability set of an existing Azure VM. The availability set must be specified at creation time. Therefore, the only way to add VM1 to AS1 is to delete and recreate…

Maintain SAP workloads on Azure

Question

Drag and Drop Question You have an Azure subscription that contains an availability set named AS1 and a virtual machine named VM1. VM1 hosts an SAP NetWeaver application. You need to ensure that AS1 includes VM1. Which four PowerShell cmdlets should you run in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order. Answer:

Exhibit

AZ-120 question #158 exhibit

Answer Area

Drag items

Set-AzVMOSDiskRemove-AzVMNew-AzVMNew-AzVMConfigUpdate-AzAvailabilitySet

Correct arrangement

  • Set-AzVMOSDisk
  • Remove-AzVM
  • New-AzVMConfig
  • Update-AzAvailabilitySet

Explanation

Explanation: Adding a VM to an Availability Set in Azure PowerShell

Core Concept First

You cannot modify the availability set of an existing Azure VM. The availability set must be specified at creation time. Therefore, the only way to add VM1 to AS1 is to delete and recreate VM1, preserving its OS disk.


The Given Arrangement - and Why It's Suspicious

Honest assessment: the "correct arrangement" as listed appears to be from an unreliable exam prep source and is technically questionable.

Here's the problem with each placement:

#CmdletIssue
1Set-AzVMOSDiskOperates on a VM config object - but no config object exists yet at this point
2Remove-AzVMLogically correct here - deletes VM, preserves disk
3New-AzVMConfigShould come before Set-AzVMOSDisk, not after
4Update-AzAvailabilitySetUpdates AS properties (e.g., converts to managed), does not create the VM or add it to the AS

The notable omission: New-AzVM is excluded, yet it's the cmdlet that actually creates the new VM. This makes the sequence incomplete - the VM is deleted but never recreated.


The Technically Correct Sequence

The actual Microsoft-documented process is:

1. Remove-AzVM          → Delete VM1 (OS disk is preserved)
2. New-AzVMConfig       → Create new config object with -AvailabilitySetId AS1
3. Set-AzVMOSDisk       → Attach the existing OS disk to the new config
4. New-AzVM             → Recreate VM1, now bound to AS1

Update-AzAvailabilitySet is the distractor here - it updates AS properties (like converting to managed disks), but does not add a VM to the set.


Common Misconceptions

  • "You can just call Update-AzAvailabilitySet to add a VM" - No. That cmdlet modifies the AS object (fault domains, managed support), not VM membership.
  • "You can update a running VM's availability set" - No. Azure locks this at creation time.
  • "Set-AzVMOSDisk can run without a config object" - No. It always requires -VM $vmConfigObject as input, so New-AzVMConfig must run first.

Bottom Line for the Exam

If you see this question on a real Microsoft exam (AZ-104 etc.), the answer you should expect is:

Remove-AzVM → New-AzVMConfig → Set-AzVMOSDisk → New-AzVM

The arrangement listed in your materials looks like it came from a low-quality practice test. Cross-reference with Microsoft's official documentation to be safe.

Topics

#availability set#PowerShell#VM reconfiguration#Azure PowerShell cmdlets

Community Discussion

No community discussion yet for this question.

Full AZ-120 Practice