Skip to content

az storage blob sync requires 'az login' when using --account-key #32048

@AurimasNav

Description

@AurimasNav

Describe the bug

in 2.76.0 this works fine:
az storage blob sync --account-name $STORAGE_ACCOUNT_NAME --account-key $ACCOUNT_KEY --container stuff --source "./assets" --destination "assets"

in 2.77.0 it results in error:

ERROR: Please run 'az login' to setup account.

providing --auth-mode key parameter or env var AZURE_STORAGE_AUTH_MODE=key still results in error, making it impossible to use --account-key authentication.

Related command

az storage blob sync

Errors

ERROR: Please run 'az login' to setup account.

Issue script & Debug output

DEBUG: cli.knack.cli: Command arguments: ['storage', 'blob', 'sync', '--account-name', 'storageaccname', '--account-key', XXX', '--container', 'stuff', '--source', './assets', '--destination', 'assets', '--delete-destination', 'true', '--debug']
DEBUG: cli.knack.cli: init debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7ffffedbfb00>, <function OutputProducer.on_global_arguments at 0x7ffffea1aac0>, <function CLIQuery.on_global_arguments at 0x7ffffea5c040>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'storage': ['azure.cli.command_modules.storage']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: storage 0.095 60 275
DEBUG: cli.azure.cli.core: Total (1) 0.095 60 275
DEBUG: cli.azure.cli.core: Loaded 60 groups, 275 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : storage blob sync
DEBUG: cli.azure.cli.core: Command table: storage blob sync
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7ffffd9e23e0>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/root/.azure/commands/2025-09-03.07-59-42.storage_blob_sync.15.log'.
INFO: az_command_data_logger: command args: storage blob sync --account-name {} --account-key {} --container {} --source {} --destination {} --delete-destination {} --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7ffffda26520>]
DEBUG: cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/venv/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1310, in _find_and_load_unlocked
File "", line 488, in _call_with_frames_removed
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.mgmt.storage.blob'

DEBUG: cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/venv/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.mgmt.storage.file'

DEBUG: cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/venv/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1310, in _find_and_load_unlocked
File "", line 488, in _call_with_frames_removed
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.mgmt.storage.file'

DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7ffffda49080>, <function register_cache_arguments..add_cache_arguments at 0x7ffffda49260>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x7ffffda49300>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7ffffea1ab60>, <function CLIQuery.handle_query_parameter at 0x7ffffea5c0e0>, <function register_ids_argument..parse_ids_arguments at 0x7ffffda49120>]
WARNING: This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
WARNING: Positional argument '<EXTRA_OPTIONS>' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
INFO: cli.azure.cli.command_modules.storage._validators: Try to get storage auth_mode value from environment variables or config file.
INFO: cli.azure.cli.command_modules.storage._validators: Try to get storage sas_token value from environment variables or config file.
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/venv/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/command_modules/storage/init.py", line 358, in new_handler
first(ex)
File "/venv/lib/python3.12/site-packages/azure/cli/command_modules/storage/init.py", line 357, in new_handler
raise ex
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 94, in storage_blob_sync
azcopy = _azcopy_blob_client(cmd, client)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 132, in _azcopy_blob_client
return AzCopy(creds=client_auth_for_azcopy(cmd, client))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 151, in client_auth_for_azcopy
raw_token = Profile(cli_ctx=cmd.cli_ctx).get_raw_token(resource=STORAGE_RESOURCE_ENDPOINT)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/_profile.py", line 359, in get_raw_token
account = self.get_subscription(subscription)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.12/site-packages/azure/cli/core/_profile.py", line 558, in get_subscription
raise CLIError(_AZ_LOGIN_MESSAGE)
knack.util.CLIError: Please run 'az login' to setup account.

ERROR: cli.azure.cli.core.azclierror: Please run 'az login' to setup account.
ERROR: az_command_data_logger: Please run 'az login' to setup account.
DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7ffffd9e2660>]
INFO: az_command_data_logger: exit code: 1
INFO: cli.main: Command ran in 0.494 seconds (init: 0.121, invoke: 0.373)
INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
INFO: telemetry.client: Accumulated 0 events. Flush the clients.
INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
INFO: telemetry.save: Save telemetry record of length 3748 in cache
INFO: telemetry.main: Begin creating telemetry upload process.
INFO: telemetry.process: Creating upload process: "/venv/bin/python3 /venv/lib/python3.12/site-packages/azure/cli/telemetry/init.py /root/.azure"
INFO: telemetry.process: Return from creating process
INFO: telemetry.main: Finish creating telemetry upload process.
WARNING: This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
WARNING: Positional argument '<EXTRA_OPTIONS>' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
ERROR: Please run 'az login' to setup account.

Expected behavior

directory synced to storage account

Environment Summary

azure-cli 2.77.0

core 2.77.0
telemetry 1.1.0

Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0

Python location '/venv/bin/python3'
Config directory '/root/.azure'
Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.12.11 (main, Jun 9 2025, 08:58:11) [GCC 14.2.0]

Additional context

No response

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-IssueStorageaz storagecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions