diff --git a/src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/account.py b/src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/account.py index a0821d2e6..96e3b4d89 100644 --- a/src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/account.py +++ b/src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/account.py @@ -2,6 +2,7 @@ from azure.cli._profile import Profile from azure.cli.commands import CommandTable from azure.cli._locale import L from .command_tables import COMMAND_TABLES +from azure.cli._logging import logger command_table = CommandTable() @@ -21,13 +22,17 @@ def list_subscriptions(_): """ profile = Profile() subscriptions = profile.load_cached_subscriptions() - + if not subscriptions: + logger.warning('Please run "az login" to access your accounts.') return subscriptions @command_table.command('account set') @command_table.description(L('Set the current subscription')) -@command_table.option('--subscription-id -n', metavar='SUBSCRIPTION_ID', dest='subscription_id', - help=L('Subscription Id, unique name also works.')) +@command_table.option('--subscription-name-or-id -n', + metavar='SUBSCRIPTION_NAME_OR_ID', + dest='subscription_name_or_id', + help=L('Subscription Id, unique name also works.'), + required=True) def set_active_subscription(args): """ type: command @@ -40,9 +45,9 @@ def set_active_subscription(args): - name: foo example text: example details """ - subscription_id = args.get('subscription-id') + subscription_name_or_id = args.get('subscription-name-or-id') if not id: raise ValueError(L('Please provide subscription id or unique name.')) profile = Profile() - profile.set_active_subscription(subscription_id) + profile.set_active_subscription(subscription_name_or_id)