0
0
Azurecloud~10 mins

VM states (running, stopped, deallocated) in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Arunning
Bstopped
Cdeallocated
Dstarting
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stopped' or 'deallocated' instead of 'running'.
2fill in blank
medium

Complete 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'
Astart
Bdeallocate
Crestart
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deallocate' instead of 'stop' when the goal is just to stop the VM.
3fill in blank
hard

Fix 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'
Astop
Bshutdown
Cdeallocate
Dpoweroff
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stop' which only powers off the VM but does not release resources.
4fill in blank
hard

Fill 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'
Astopped
Brunning
Cdeallocated
Dstarting
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'running' or 'starting' as non-running states.
5fill in blank
hard

Fill 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'
Arunning
Bstopped
Cdeallocated
Dstarting
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'stopped' and 'deallocated' meanings.