Complete the code to check if the Azure VM is currently running.
if vm.instance_view.statuses[1].code == 'PowerState/[1]': print('VM is running')
The VM's power state code for a running VM is 'PowerState/running'.
Complete the code to stop an Azure VM using the Azure CLI command.
az vm [1] --name MyVM --resource-group MyResourceGroupThe 'az vm stop' command stops the VM but does not release the compute resources.
Fix the error in the Azure CLI command to deallocate a VM.
az vm [1] --name MyVM --resource-group MyResourceGroupThe correct command to release compute resources and deallocate the VM is 'az vm deallocate'.
Fill both blanks to check if the VM is either stopped or deallocated.
if vm.instance_view.statuses[1].code == 'PowerState/[1]' or vm.instance_view.statuses[1].code == 'PowerState/[2]': print('VM is not running')
The VM states 'stopped' and 'deallocated' both mean the VM is not running.
Fill all three blanks to create a dictionary mapping VM states to their meanings.
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'
}This dictionary clearly maps each VM state to its description.
