from azure.mgmt.compute import ComputeManagementClient
print("Starting script")
SUBSCRIPTION_ID = "mysubscriptionid"
credential = ClientSecretCredential(
tenant_id='mytenantid,
client_id='myapplicationid,
client_secret='myapplicationsecret'
)
compute_client = ComputeManagementClient(
credential=credential,
subscription_id=SUBSCRIPTION_ID,
)
print("Getting vms")
# List all Virtual Machines in the specified subscription
def list_virtual_machines():
for vm in compute_client.virtual_machines.list_all():
print(vm.name)
list_virtual_machines()
Errors encountered and fixes.
Packages not found
Solution :
Install the packages using
pip install packagename
pip error while installing packages.
pip install azure-storage Defaulting to user installation because normal site-packages is not writeable WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1,