Last active
December 25, 2015 20:19
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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