Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/azure-cli/azure/cli/command_modules/storage/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,18 @@ def validate_client_parameters(cmd, namespace):

# if account name is specified but no key, attempt to query
if n.account_name and not n.account_key and not n.sas_token:
logger.warning('There are no credentials provided in your command and environment, we will query for the '
'account key inside your storage account. \nPlease provide --connection-string, '
'--account-key or --sas-token as credentials, or use `--auth-mode login` if you '
'have required RBAC roles in your command. For more information about RBAC roles '
'in storage, visit '
'https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-cli. \n'
'Setting the corresponding environment variables can avoid inputting credentials in '
'your command. Please use --help to get more information.')
message = """
There are no credentials provided in your command and environment, we will query for account key for your storage account.
It is recommended to provide --connection-string, --account-key or --sas-token in your command as credentials.
"""
if 'auth_mode' in cmd.arguments:
message += """
You also can add `--auth-mode login` in your command to use Azure Active Directory (Azure AD) for authorization if your login account is assigned required RBAC roles.
For more information about RBAC roles in storage, visit https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-cli.
"""
logger.warning('%s\nIn addition, setting the corresponding environment variables can avoid inputting '
'credentials in your command. Please use --help to get more information about environment '
'variable usage.', message)
try:
n.account_key = _query_account_key(cmd.cli_ctx, n.account_name)
except Exception as ex: # pylint: disable=broad-except
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def get_models(self, *attr_args, **_):


class MockCmd(object):
def __init__(self, ctx):
def __init__(self, ctx, arguments={}):
self.cli_ctx = ctx
self.loader = MockLoader(self.cli_ctx)
self.arguments = arguments

def get_models(self, *attr_args, **kwargs):
return get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE, *attr_args, **kwargs)
Expand Down