Search code examples
azureazure-virtual-machineautoscalingazure-monitoringazure-autoscaling-block

Monitoring instances in Azure Virtual Machine Scale Set (VMSS) using Python


I want to monitor and get information regarding the different instances in an Azure Virtual Machine Scale Set (VMSS).

I used the command (Python):

vmss = compute_client.virtual_machine_scale_sets.list(resource_group, scale_set_name)

But I am not able to get the result I am expecting.

Any suggestions what to do?


Solution

  • If you want to get the VMs information, please use the following code.

    subscription_id = 'subscription Id'
    credentials = ServicePrincipalCredentials(client_id=CLIENT, secret=KEY, tenant=TENANT_ID)
    client = ComputeManagementClient(credentials, subscription_id)
    vmss = client.virtual_machine_scale_set_vms.list("resourcegroup Name","VMSS name")
    for item in vmss:  
        print("id:",item.id)
        print("name",item.name)
    

    Test Result:

    enter image description here