diff --git a/azure-cli.pyproj b/azure-cli.pyproj index f0c24e1b38b..2baefee116a 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -30,6 +30,7 @@ Code + diff --git a/src/azure/cli/_debug.py b/src/azure/cli/_debug.py new file mode 100644 index 00000000000..f667cab3941 --- /dev/null +++ b/src/azure/cli/_debug.py @@ -0,0 +1,11 @@ +import os + +def allow_debug_connection(client): + if should_allow_debug_connection(): + client.config.connection.verify = False + +def should_allow_debug_connection(): + try: + return bool(os.environ['AllowDebug']) + except KeyError: + return False \ No newline at end of file diff --git a/src/azure/cli/commands/login.py b/src/azure/cli/commands/login.py index b84fb4fb846..e466d50deed 100644 --- a/src/azure/cli/commands/login.py +++ b/src/azure/cli/commands/login.py @@ -6,6 +6,7 @@ from .._profile import Profile from .._util import TableOutput from ..commands import command, description, option +import azure.cli._debug as _debug CLIENT_ID = '04b07795-8ddb-461a-bbee-02f9e1bf7b46' @@ -21,8 +22,9 @@ def login(args, unexpected): import getpass password = getpass.getpass(_('Password: ')) - credentials = UserPassCredentials(username, password, client_id=CLIENT_ID) + credentials = UserPassCredentials(username, password, client_id=CLIENT_ID, verify=_debug.should_allow_debug_connection()) client = SubscriptionClient(SubscriptionClientConfiguration(credentials)) + _debug.allow_debug_connection(client) subscriptions = client.subscriptions.list() if not subscriptions: diff --git a/src/azure/cli/commands/storage.py b/src/azure/cli/commands/storage.py index cf1bef0617c..3c57ed279b1 100644 --- a/src/azure/cli/commands/storage.py +++ b/src/azure/cli/commands/storage.py @@ -3,6 +3,7 @@ from .._util import TableOutput from ..commands import command, description, option from .._profile import Profile +import azure.cli._debug as _debug @command('storage account list') @description('List storage accounts') @@ -16,8 +17,9 @@ def list_accounts(args, unexpected): profile = Profile() #credentials, subscription_id = profile.get_credentials() smc = StorageManagementClient(StorageManagementClientConfiguration( - *profile.get_credentials(), + *profile.get_credentials() )) + _debug.allow_debug_connection(smc) group = args.get('resource-group') if group: