Oliver Oliver - 2 months ago 17
Python Question

Azure python sdk - getting the machine state

Using the python api for azure, I want to get the state of one of my machines.

I can't find anywhere to access this information.

Does someone know?

After looking around, I found this:

get_with_instance_view(resource_group_name, vm_name)


https://azure-sdk-for-python.readthedocs.org/en/latest/ref/azure.mgmt.compute.computemanagement.html#azure.mgmt.compute.computemanagement.VirtualMachineOperations.get_with_instance_view

Answer

In the new API resource manager There's a function:

get_with_instance_view(resource_group_name, vm_name)

It's the same function as get machine, but it also returns an instance view that contains the machine state.

https://azure-sdk-for-python.readthedocs.org/en/latest/ref/azure.mgmt.compute.computemanagement.html#azure.mgmt.compute.computemanagement.VirtualMachineOperations.get_with_instance_view