0
votes

I have a python script which simply lists the VMs in a resource group. It was working in the past but for some reason has stopped producing output. All other commands in my script work, it is just this one that is giving me bother. My code is as follows:

credentials = MSIAuthentication()
subscription_client = SubscriptionClient(credentials)
subscription = next(subscription_client.subscriptions.list())
subscription_id = subscription.subscription_id
compute_client = ComputeManagementClient(credentials, subscription_id)

resourceGroup = "myResourceGroup"
for vm in compute_client.virtual_machines.list(resourceGroup):
    print(vm)

I have also tried appending an older API version but still nothing is printed. I can confirm there are VMs in this resource group.

I have a similar command for listing VMs in VMSS groups, and it works fine.

Does anyone know what could be the issue with this particular command?

1
It seems that there is no issue with command. It works correctly on my side. It was working in the past but for some reason has stopped producing output Is there any error information?Tom Sun - MSFT

1 Answers

2
votes

Answering my own question.

The problem stemmed from having incorrect/missing permissions in the custom role applied to the server. Ensure that your custom role has the 'Microsoft.Compute/virtualMachines/read' permissions.