0

I have written the code to list down the Azure Virtual Machines. but I am getting this error. when I try pip install msrest or pip install msrestazure. none of the commands works. It neither gives error nor starts the installation. enter image description here

Traceback (most recent call last): File "d:\FYP\FYP\AzureVms.py", line 1, in from azure.common.credentials import ServicePrincipalCredentials File "d:\FYP\FYP\Azure\lib\site-packages\azure\common\credentials.py", line 171, in raise ImportError("You need to install 'msrestazure' to use this feature") ImportError: You need to install 'msrestazure' to use this feature

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient

credential = ServicePrincipalCredentials(client_id='XXXX', secret='XXXX',tenant='XXXX')
compute_client = ComputeManagementClient(
    credential, 'XXXX')

def list_virtual_machines():
    for vm in compute_client.virtual_machines.list_all():
        print(vm.name)
Hassan Turi
  • 334
  • 3
  • 14

1 Answers1

2

ModuleNotFoundError: No module named 'msrestazure'

In your python project, install Pandas library and msrestazure python with following command:

pip install msrestazure

After the installation of msrestazure python library, the above error will be solved.


To get/print the VM details using python code, refer this microsoft documentation given practical code.