Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the Azure VM is currently running.
Azure
if vm.instance_view.statuses[1].code == 'PowerState/[1]': print('VM is running')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stopped' or 'deallocated' instead of 'running'.
✗ Incorrect
The VM's power state code for a running VM is 'PowerState/running'.
2fill in blank
mediumComplete the code to stop an Azure VM using the Azure CLI command.
Azure
az vm [1] --name MyVM --resource-group MyResourceGroup Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deallocate' instead of 'stop' when the goal is just to stop the VM.
✗ Incorrect
The 'az vm stop' command stops the VM but does not release the compute resources.
3fill in blank
hardFix the error in the Azure CLI command to deallocate a VM.
Azure
az vm [1] --name MyVM --resource-group MyResourceGroup Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stop' which only powers off the VM but does not release resources.
✗ Incorrect
The correct command to release compute resources and deallocate the VM is 'az vm deallocate'.
4fill in blank
hardFill both blanks to check if the VM is either stopped or deallocated.
Azure
if vm.instance_view.statuses[1].code == 'PowerState/[1]' or vm.instance_view.statuses[1].code == 'PowerState/[2]': print('VM is not running')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'running' or 'starting' as non-running states.
✗ Incorrect
The VM states 'stopped' and 'deallocated' both mean the VM is not running.
5fill in blank
hardFill all three blanks to create a dictionary mapping VM states to their meanings.
Azure
vm_states = {
'[1]': 'VM is powered on and running',
'[2]': 'VM is powered off but resources allocated',
'[3]': 'VM is powered off and resources released'
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'stopped' and 'deallocated' meanings.
✗ Incorrect
This dictionary clearly maps each VM state to its description.