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.
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)