Bird
Raised Fist0
Azurecloud~10 mins

VM commands (create, start, stop) in Azure - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - VM commands (create, start, stop)
Create VM Command
↓
VM Created in Running State
↓
Start VM Command
↓
VM State: Running (no change)
↓
Stop VM Command
↓
VM State: Stopped
↓
End
This flow shows creating a VM (starts running), then starting it (no effect), and finally stopping it back to a stopped state.
Execution Sample
Azure
az vm create --name MyVM --resource-group MyGroup --image UbuntuLTS --generate-ssh-keys
az vm start --name MyVM --resource-group MyGroup
az vm stop --name MyVM --resource-group MyGroup
Commands to create a VM (starts running), start it (no effect), and then stop it in Azure.
Process Table
StepCommandVM State BeforeActionVM State After
1az vm create --name MyVM --resource-group MyGroup --image UbuntuLTS --generate-ssh-keysNoneCreate VM (starts in running state)Running
2az vm start --name MyVM --resource-group MyGroupRunningStart VM (no effect)Running
3az vm stop --name MyVM --resource-group MyGroupRunningStop VMStopped
4No further commandsStoppedEnd of commandsStopped
💡 No more commands; VM remains in stopped state.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
VM StateNoneRunningRunningStoppedStopped
Key Moments - 3 Insights
Why is the VM state 'Running' immediately after creation?
Because Azure creates the VM in a running state by default as shown in execution_table step 1.
What happens if you try to start a VM that is already running?
The VM remains running; starting a running VM has no effect, as implied by the state change in step 2.
Does stopping the VM delete it?
No, stopping only changes the state to 'Stopped' without deleting the VM, as shown in step 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the VM state after the create command?
ARunning
BDeleted
CStopped
DStarting
💡 Hint
Check the 'VM State After' column in step 1 of the execution_table.
At which step does the VM state change from 'Running' to 'Stopped'?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'VM State Before' and 'VM State After' columns in the execution_table.
If you run 'az vm stop' when the VM is already stopped, what would happen?
AVM state changes to Running
BVM state remains Stopped
CVM is deleted
DError occurs
💡 Hint
Refer to the VM state transitions in the variable_tracker and key_moments.
Concept Snapshot
Azure VM commands:
- Create VM: 'az vm create' creates and starts VM in running state.
- Start VM: 'az vm start' changes state to running (no effect if already running).
- Stop VM: 'az vm stop' changes state to stopped.
VM state changes but VM resource remains unless deleted.
Full Transcript
This lesson shows how to manage an Azure virtual machine using commands. First, the VM is created with 'az vm create' and starts in a running state. Next, 'az vm start' has no effect since the VM is already running. Finally, 'az vm stop' stops the VM, returning it to a stopped state without deleting it. The execution table tracks each command and the VM state before and after. The variable tracker shows the VM state changes step by step. Key moments clarify common confusions like why the VM is running after creation, what happens when starting an already running VM, and that stopping does not delete the VM. The quiz tests understanding of these state changes and command effects.

Practice

(1/5)
1. What does the az vm create command do in Azure?
easy
A. It starts an existing virtual machine.
B. It stops a running virtual machine.
C. It creates a new virtual machine in Azure.
D. It deletes a virtual machine.

Solution

  1. Step 1: Understand the command purpose

    The az vm create command is used to make a new virtual machine in Azure.
  2. Step 2: Compare with other commands

    az vm start starts a VM, az vm stop stops it, and az vm delete removes it.
  3. Final Answer:

    It creates a new virtual machine in Azure. -> Option C
  4. Quick Check:

    az vm create = create VM [OK]
Hint: Create means make new VM, start means turn on, stop means turn off [OK]
Common Mistakes:
  • Confusing create with start or stop commands
  • Thinking create also starts the VM automatically
  • Mixing stop with delete
2. Which of the following is the correct syntax to start a VM named myVM in resource group myGroup?
easy
A. az vm create --name myVM --resource-group myGroup
B. az vm start --name myVM --resource-group myGroup
C. az vm stop --name myVM --resource-group myGroup
D. az vm delete --name myVM --resource-group myGroup

Solution

  1. Step 1: Identify the command to start a VM

    The command to start a VM is az vm start.
  2. Step 2: Check the syntax for name and resource group

    The correct flags are --name for VM name and --resource-group for the group.
  3. Final Answer:

    az vm start --name myVM --resource-group myGroup -> Option B
  4. Quick Check:

    Start VM syntax = az vm start [OK]
Hint: Start VM uses 'az vm start' with --name and --resource-group [OK]
Common Mistakes:
  • Using create instead of start to power on VM
  • Forgetting to specify resource group
  • Using stop or delete commands by mistake
3. What will happen if you run this command?
az vm stop --name testVM --resource-group testGroup
medium
A. The VM named testVM will be stopped (powered off).
B. The VM named testVM will be deleted.
C. The VM named testVM will be started.
D. The command will show a syntax error.

Solution

  1. Step 1: Understand the command action

    az vm stop stops (powers off) the specified VM.
  2. Step 2: Confirm the VM and resource group names

    The VM name is testVM and resource group is testGroup, both valid inputs.
  3. Final Answer:

    The VM named testVM will be stopped (powered off). -> Option A
  4. Quick Check:

    az vm stop = stop VM [OK]
Hint: Stop command powers off VM, does not delete or start it [OK]
Common Mistakes:
  • Confusing stop with delete
  • Thinking stop starts the VM
  • Assuming syntax error due to names
4. You tried to start a VM with this command:
az vm start -n myVM -g myGroup

The command failed with an error. What is the likely cause?
medium
A. The VM name or resource group might be misspelled or does not exist.
B. You must stop the VM before starting it.
C. The flags -n and -g are incorrect; use full names instead.
D. The az vm start command cannot use short flags.

Solution

  1. Step 1: Check command flags

    -n and -g are valid short forms for --name and --resource-group.
  2. Step 2: Consider common errors

    Errors usually happen if the VM or resource group name is wrong or missing in Azure.
  3. Final Answer:

    The VM name or resource group might be misspelled or does not exist. -> Option A
  4. Quick Check:

    Invalid names cause start errors, not flags [OK]
Hint: Check VM and group names carefully if start fails [OK]
Common Mistakes:
  • Assuming short flags are invalid
  • Thinking VM must be stopped before starting
  • Confusing start errors with syntax errors
5. You want to save money by stopping a VM but keep its data intact. Which command should you use and why?
hard
A. Use az vm stop because it powers off the VM but keeps the disk data.
B. Use az vm delete because it stops and removes the VM and data.
C. Use az vm restart because it stops and starts the VM quickly.
D. Use az vm deallocate because it stops the VM and releases compute resources but keeps data.

Solution

  1. Step 1: Understand stopping vs deallocating

    az vm stop powers off the VM but does not release compute resources, so charges continue.
  2. Step 2: Identify the command to save costs

    az vm deallocate stops the VM and releases compute resources, saving money while keeping disk data.
  3. Final Answer:

    Use az vm deallocate because it stops the VM and releases compute resources but keeps data. -> Option D
  4. Quick Check:

    Deallocate = stop + release resources + keep data [OK]
Hint: Deallocate stops VM and saves cost without deleting data [OK]
Common Mistakes:
  • Using stop only and expecting cost savings
  • Deleting VM to save money loses data
  • Restarting does not save costs
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard