From 14c2cfb6bfce94918afd3409242a8d833fd5fe9f Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Mon, 20 Jan 2020 21:04:56 +0800 Subject: [PATCH] [Storage] Fix errors for storage blob update (#11907) * fix validator * update history.rst --- src/azure-cli/HISTORY.rst | 1 + .../command_modules/storage/_validators.py | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 75c654b8376..812624fa56e 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -35,6 +35,7 @@ Release History **Storage** * Add a new command group `az storage share-rm` to use the Microsoft.Storage resource provider for Azure file share management operations. +* Fix issue #11415: permission error for `az storage blob update` 2.0.80 ++++++ diff --git a/src/azure-cli/azure/cli/command_modules/storage/_validators.py b/src/azure-cli/azure/cli/command_modules/storage/_validators.py index b2efbca6362..aa0f2597556 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_validators.py @@ -112,15 +112,16 @@ def get_config_value(section, key, default): if auth_mode == 'login': n.token_credential = _create_token_credential(cmd.cli_ctx) - # give warning if there are account key args being ignored - account_key_args = [n.account_key and "--account-key", n.sas_token and "--sas-token", - n.connection_string and "--connection-string"] - account_key_args = [arg for arg in account_key_args if arg] - - if account_key_args: - logger.warning('In "login" auth mode, the following arguments are ignored: %s', - ' ,'.join(account_key_args)) - return + if hasattr(n, 'token_credential') and n.token_credential: + # give warning if there are account key args being ignored + account_key_args = [n.account_key and "--account-key", n.sas_token and "--sas-token", + n.connection_string and "--connection-string"] + account_key_args = [arg for arg in account_key_args if arg] + + if account_key_args: + logger.warning('In "login" auth mode, the following arguments are ignored: %s', + ' ,'.join(account_key_args)) + return if not n.connection_string: n.connection_string = get_config_value('storage', 'connection_string', None) @@ -369,13 +370,13 @@ def validator(cmd, namespace): key = ns.get('account_key') cs = ns.get('connection_string') sas = ns.get('sas_token') + token_credential = ns.get('token_credential') if _class_name(settings_class) == _class_name(t_blob_content_settings): client = get_storage_data_service_client(cmd.cli_ctx, - t_base_blob_service, - account, - key, - cs, - sas) + service=t_base_blob_service, + name=account, + key=key, connection_string=cs, sas_token=sas, + token_credential=token_credential) container = ns.get('container_name') blob = ns.get('blob_name') lease_id = ns.get('lease_id')