I am trying out the listing of different locations in Azure using Python Azure SDKs from Windows machine Below is the error :

Please see my code :
import os
import sys
import logging
from azure import *
from azure.servicemanagement import *
subscription_id = 'XXXXXX-XXXXX-XXXXX-XXXXX-XXXXXXXXXXXX'
certificate_path = '\.pem'
sms = ServiceManagementService(subscription_id, certificate_path)
result = sms.list_subscriptions()
for location in result:
print(location.name)

I hope this helps, you can use the new api to list locations, you don't need to use a certificate :).
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.subscription import SubscriptionClient
subscription_id = "11111111-1111-1111-1111-111111111111"
client_id = "11111111-1111-1111-1111-111111111111"
secret = "11111111-1111-1111-1111-111111111111"
tenant_id = "11111111-1111-1111-1111-111111111111"
creds = ServicePrincipalCredentials(client_id=client_id, secret=secret,
tenant=tenant_id)
subscription_client = SubscriptionClient(creds)
locations = subscription_client.subscriptions.list_locations(subscription_id)
for location in locations:
print(location.name)
generating client ID and secret can be done by running the cli command:
az ad sp create-for-rbac --sdk-auth > my.azureauth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With