Skip to content

az storage blob sync requires 'az login' when using --sas-tokenΒ #32284

@DerTim1

Description

@DerTim1

Describe the bug

In e.g. 2.72 this works fine:

az storage blob sync -c doc --account-name ACCOUNT_NAME --sas-token "$STORAGE_ACCOUNT_SAS" -s "doc" --destination "bla/blubb"

Since 2.77 this seems broken with:

cli.azure.cli.core.azclierror: Please run 'az login' to setup account.
az_command_data_logger: Please run 'az login' to setup account.

I think its related to #32048 and was probablly fixed for using --account-key. Using --sas-token still doesn't work.

Related command

az storage blob sync -c doc --account-name ACCOUNT_NAME --sas-token "$STORAGE_ACCOUNT_SAS" -s "doc" --destination "bla/blubb"

Errors

cli.azure.cli.core.azclierror: Please run 'az login' to setup account.
az_command_data_logger: Please run 'az login' to setup account.

Issue script & Debug output

cli.knack.cli: Command arguments: ['storage', 'blob', 'sync', '--debug', '-c', 'doc', '--account-name', 'SKIPPED', '--sas-token', '?sp=racwdli&st=2025-10-20T06:50:25Z&se=2025-10-20T15:05:25Z&spr=https&sv=2024-11-04&sr=c&sig=SKIPPED', '-s', 'doc', '--destination', 'nl_deployment_task/1.3.0/', '--service-endpoint', 'SKIPPED']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x70dd6fa46520>, <function OutputProducer.on_global_arguments at 0x70dd6f7fb9c0>, <function CLIQuery.on_global_arguments at 0x70dd6f82de40>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Command index version or cloud profile is invalid or doesn't match the current command.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core: Command index has been invalidated.
cli.azure.cli.core: No module found from index for '['storage', 'blob', 'sync', '--debug', '-c', 'doc', '--account-name', 'SKIPPED', '--sas-token', '?sp=racwdli&st=2025-10-20T06:50:25Z&se=2025-10-20T15:05:25Z&spr=https&sv=2024-11-04&sr=c&sig=SKIPPED', '-s', 'doc', '--destination', 'nl_deployment_task/1.3.0/', '--service-endpoint', 'SKIPPED']'
cli.azure.cli.core: Loading all modules and extensions
cli.azure.cli.core: Discovered command modules: ['acr', 'acs', 'advisor', 'ams', 'apim', 'appconfig', 'appservice', 'aro', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'compute_recommender', 'computefleet', 'config', 'configure', 'consumption', 'container', 'containerapp', 'cosmosdb', 'databoxedge', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'identity', 'interactive', 'iot', 'keyvault', 'lab', 'managedservices', 'maps', 'marketplaceordering', 'monitor', 'mysql', 'netappfiles', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'resource', 'role', 'search', 'security', 'servicebus', 'serviceconnector', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'synapse', 'util', 'vm']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acr 0.110 36 149
cli.azure.cli.core: acs 0.079 17 88
cli.azure.cli.core: advisor 0.001 3 6
cli.azure.cli.core: ams 0.003 22 100
cli.azure.cli.core: apim 0.003 14 69
cli.azure.cli.core: appconfig 0.002 9 47
cli.azure.cli.core: appservice 0.015 81 280
cli.azure.cli.core: aro 0.006 1 10
cli.azure.cli.core: backup 0.002 16 61
cli.azure.cli.core: batch 0.036 32 96
cli.azure.cli.core: batchai 0.002 10 30
cli.azure.cli.core: billing 0.009 19 53
cli.azure.cli.core: botservice 0.002 12 42
cli.azure.cli.core: cdn 0.130 8 51
cli.azure.cli.core: cloud 0.001 1 7
cli.azure.cli.core: cognitiveservices 0.002 10 33
cli.azure.cli.core: compute_recommender 0.002 1 1
cli.azure.cli.core: computefleet 0.005 1 1
cli.azure.cli.core: config 0.001 2 7
cli.azure.cli.core: configure 0.001 2 5
cli.azure.cli.core: consumption 0.010 8 9
cli.azure.cli.core: container 0.006 2 17
cli.azure.cli.core: containerapp 0.070 37 123
cli.azure.cli.core: cosmosdb 0.008 58 200
cli.azure.cli.core: databoxedge 0.005 2 2
cli.azure.cli.core: dls 0.002 6 36
cli.azure.cli.core: dms 0.001 3 22
cli.azure.cli.core: eventgrid 0.003 25 96
cli.azure.cli.core: eventhubs 0.007 13 20
cli.azure.cli.core: extension 0.001 1 7
cli.azure.cli.core: feedback 0.000 1 2
cli.azure.cli.core: find 0.001 1 1
cli.azure.cli.core: hdinsight 0.004 9 42
cli.azure.cli.core: identity 0.004 2 7
cli.azure.cli.core: interactive 0.000 1 1
cli.azure.cli.core: iot 0.055 18 81
cli.azure.cli.core: keyvault 0.005 20 114
cli.azure.cli.core: lab 0.019 9 30
cli.azure.cli.core: managedservices 0.006 3 8
cli.azure.cli.core: maps 0.001 5 13
cli.azure.cli.core: marketplaceordering 0.001 1 2
cli.azure.cli.core: monitor 0.331 18 63
cli.azure.cli.core: mysql 0.056 16 56
cli.azure.cli.core: netappfiles 0.027 8 15
cli.azure.cli.core: network 0.092 106 351
cli.azure.cli.core: policyinsights 0.007 9 17
cli.azure.cli.core: privatedns 0.011 14 60
cli.azure.cli.core: profile 0.001 2 8
cli.azure.cli.core: rdbms 0.060 52 217
cli.azure.cli.core: redis 0.002 7 38
cli.azure.cli.core: relay 0.013 7 8
cli.azure.cli.core: resource 0.023 52 234
cli.azure.cli.core: role 0.002 17 62
cli.azure.cli.core: search 0.005 7 20
cli.azure.cli.core: security 0.006 48 98
cli.azure.cli.core: servicebus 0.005 14 17
cli.azure.cli.core: serviceconnector 0.037 20 331
cli.azure.cli.core: servicefabric 0.008 27 80
cli.azure.cli.core: signalr 0.002 10 42
cli.azure.cli.core: sql 0.009 56 219
cli.azure.cli.core: sqlvm 0.017 4 20
cli.azure.cli.core: storage 0.035 62 278
cli.azure.cli.core: synapse 0.007 54 246
cli.azure.cli.core: util 0.001 3 7
cli.azure.cli.core: vm 0.070 60 209
cli.azure.cli.core: Total (65) 1.447 1195 4665
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: account 0.003 4 12 /home/td/.azure/cliextensions/account
cli.azure.cli.core: dataprotection 0.008 11 45 /home/td/.azure/cliextensions/dataprotection
cli.azure.cli.core: k8s-extension 0.003 2 9 /home/td/.azure/cliextensions/k8s-extension
cli.knack.cli: Event: CommandLoader.OnLoadCommandTable []
cli.azure.cli.core: storage-preview 0.007 14 36 /home/td/.azure/cliextensions/storage-preview
cli.azure.cli.core: Total (4) 0.021 31 102
cli.azure.cli.core: Loaded 1203 groups, 4753 commands.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core._session: Skipping update of file /nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/etc/azure/commandIndex.json due to immutable directory.
cli.azure.cli.core: Updated command index in 0.003 seconds.
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x70dd6e1b5440>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/td/.azure/commands/2025-10-20.09-07-30.storage_blob_sync.56663.log'.
az_command_data_logger: command args: storage blob sync --debug -c {} --account-name {} --sas-token {} -s {} --destination {} --service-endpoint {}
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x70dd6e1f7560>]
cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/importlib/init.py", line 88, 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'

cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/importlib/init.py", line 88, 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'

cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/profiles/_shared.py", line 454, in _get_attr
op = import_module(full_mod_path)
File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/importlib/init.py", line 88, 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'

cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x70dd6e20d8a0>, <function register_cache_arguments..add_cache_arguments at 0x70dd6e20da80>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x70dd6e20db20>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x70dd6c13f740>]
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x70dd6f7fba60>, <function CLIQuery.handle_query_parameter at 0x70dd6f82dee0>, <function register_ids_argument..parse_ids_arguments at 0x70dd6e20d940>]
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Positional argument '<EXTRA_OPTIONS>' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.command_modules.storage._validators: Try to get storage auth_mode value from environment variables or config file.
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/nix/store/fyf0psacfzfqyrnjiprcnd1c9mmrla5k-python3.13-knack-0.12.0/lib/python3.13/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/init.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
File "/nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/lib/python3.13/site-packages/azure/cli/command_modules/storage/init.py", line 358, in new_handler
first(ex)
~~~~~^^^^
File "/nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/lib/python3.13/site-packages/azure/cli/command_modules/storage/init.py", line 357, in new_handler
raise ex
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/lib/python3.13/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 94, in storage_blob_sync
azcopy = _azcopy_blob_client(cmd, client)
File "/nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/lib/python3.13/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 "/nix/store/0k0zbk6bj6s8fmh8yvpi2q84avhrr8kp-python3.13-azure-cli-2.78.0/lib/python3.13/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 165, in client_auth_for_azcopy
raw_token = Profile(cli_ctx=cmd.cli_ctx).get_raw_token(resource=STORAGE_RESOURCE_ENDPOINT)
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/site-packages/azure/cli/core/_profile.py", line 359, in get_raw_token
account = self.get_subscription(subscription)
File "/nix/store/l8rvwrkmmyclh3wqk1ac9fjrn6hcvxyb-python3.13-azure-cli-core-2.78.0/lib/python3.13/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.

cli.azure.cli.core.azclierror: Please run 'az login' to setup account.
az_command_data_logger: Please run 'az login' to setup account.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x70dd6e1b56c0>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 2.217 seconds (init: 0.293, invoke: 1.925)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3887 in cache file under /home/td/.azure/telemetry/20251020090731129
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/bin/python3.13 /nix/store/43s7d48xp0jsk3shg3y9varrmvinw0gh-python3.13-azure-cli-telemetry-1.1.0/lib/python3.13/site-packages/azure/cli/telemetry/init.py /home/td/.azure /home/td/.azure/telemetry/20251020090731129"
telemetry.process: Return from creating process 56670
telemetry.main: Finish creating telemetry upload process.

Expected behavior

Upload/sync files to storage account.

Environment Summary

azure-cli 2.78.0

core 2.78.0
telemetry 1.1.0

Extensions:
account 0.2.1
dataprotection 0.8.0
k8s-extension 1.4.3
storage-preview 0.7.1

Dependencies:
msal 1.33.0
azure-mgmt-resource 24.0.0

Python location '/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/bin/python3.13'
Config directory '/home/td/.azure'
Extensions directory '/home/td/.azure/cliextensions'

Python (Linux) 3.13.7 (main, Aug 14 2025, 11:12:11) [GCC 14.3.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

Metadata

Metadata

Assignees

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-IssuequestionThe 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