Skip to content Skip to sidebar Skip to footer

Get Vm Status Using Azure Python Sdk

I have a list of VMs and I'd like to get each VM's status (ReadyRole/Stopped/StoppedDeallocated) using Azure's Python SDK. I have done this in a bash terminal using azure cli comma

Solution 1:

Base on my experience, we can get every instances status using Azure REST API. So Azure SDK for python should have similar method, because the functions in Azure SDK use the same URL as REST API. I tried to use this method get_deployment_by_name to get the instances status:

subscription_id = '****-***-***-**'certificate_path = 'CURRENT_USER\\my\\***'sms = ServiceManagementService(subscription_id, certificate_path)
result=sms.get_deployment_by_name("your service name","your deployment name")

You can get the role list and check the every role property, please see this picture: enter image description here

Post a Comment for "Get Vm Status Using Azure Python Sdk"