Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Last active December 25, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/7033645 to your computer and use it in GitHub Desktop.
Save codingoutloud/7033645 to your computer and use it in GitHub Desktop.
Run Windows Azure Service Management operation through Python. This requires access to a certificate. Under Windows this certificate must be in the certificate store. On Mac or Linux, this certificate must accessible in a .pem file. In either case, the specified certificate must be uploaded to the Windows Azure portal as a management certificate…
from azure.servicemanagement import *
import platform
import os
###
print("CHANGE THE VALUE of 'subscription_id' and create the correct certificate or this will NOT WORK")
###
plat = platform.system()
print("Platform == " + plat)
if plat != 'Windows': ## <= ugh - IronPython returns 'cli' for this value, and Mac 2.7 returns 'Darwin', so beware - not robust!
certificate_path = './mycert.pem' # other than Windows
else:
certificate_path = 'CURRENT_USER\\my\\LabX' # Windows only
subscription_id = '01234567-89AB-CDEF-0123-456789ABCDEF'
sms = ServiceManagementService(subscription_id, certificate_path)
sub_quota = sms.get_subscription();
print('Using %s of %s cores' % (sub_quota.current_core_count, sub_quota.max_core_count))
print('Using %s of %s hosted services' % (sub_quota.current_hosted_services, sub_quota.max_hosted_services))
print('Using %s of %s storage accounts' % (sub_quota.current_storage_accounts, sub_quota.max_storage_accounts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment