本文整理匯總了Python中azure.cli._profile.Profile.set_active_subscription方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.set_active_subscription方法的具體用法?Python Profile.set_active_subscription怎麽用?Python Profile.set_active_subscription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類azure.cli._profile.Profile
的用法示例。
在下文中一共展示了Profile.set_active_subscription方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_set_active_subscription
# 需要導入模塊: from azure.cli._profile import Profile [as 別名]
# 或者: from azure.cli._profile.Profile import set_active_subscription [as 別名]
def test_set_active_subscription(self):
storage_mock = {'subscriptions': None}
profile = Profile(storage_mock)
consolidated = Profile._normalize_properties(self.user1,
[self.subscription1],
False,
ENV_DEFAULT)
profile._set_subscriptions(consolidated)
consolidated = profile._normalize_properties(self.user2,
[self.subscription2],
False,
ENV_DEFAULT)
profile._set_subscriptions(consolidated)
subscription1 = storage_mock['subscriptions'][0]
subscription2 = storage_mock['subscriptions'][1]
self.assertTrue(subscription2['isDefault'])
profile.set_active_subscription(subscription1['id'])
self.assertFalse(subscription2['isDefault'])
self.assertTrue(subscription1['isDefault'])
示例2: set_active_subscription
# 需要導入模塊: from azure.cli._profile import Profile [as 別名]
# 或者: from azure.cli._profile.Profile import set_active_subscription [as 別名]
def set_active_subscription(subscription_name_or_id):
'''Set the current subscription'''
if not id:
raise CLIError('Please provide subscription id or unique name.')
profile = Profile()
profile.set_active_subscription(subscription_name_or_id)