On the azure-cli docker image, 10.13.0 of azcopy is unavailable and so az storage copy fails
Describe the bug
the docker images
- mcr.microsoft.com/azure-cli:latest
- mcr.microsoft.com/azure-cli:2.67.0
and presumably others which use the azure linux operating system, using tdnf as the package manager don't have azcopy version 10.13.0 available and so when trying to run:
az storage copyor any other command that delegates out to azcopy fails.
Related command
docker run mcr.microsoft.com/azure-cli:latest az storage copy \
--source "https://${storageAccountName}.blob.core.windows.net/${containerName}/" \
--destination "https://${storageAccountName}.blob.core.windows.net/${containerName}/" \
--recursive \
--source-account-name "$storageAccountName" \
--account-name "$storageAccountName" \
--auth-mode "key" \
--account-key "$STORAGE_AZURE_ACCOUNTKEY" \
--source-account-key "$STORAGE_AZURE_ACCOUNTKEY"
reproduces the issue for me
Errors
WARNING: Positional argument '<EXTRA_OPTIONS>' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus WARNING: Azcopy not found, installing at /root/.azure/bin/azcopy ERROR: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>)
Issue script & Debug output
DEBUG: cli.knack.cli: Command arguments: ['storage', 'copy', '--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 0xffff831b5120>, <function OutputProducer.on_global_arguments at 0xffff82f20cc0>, <function CLIQuery.on_global_arguments at 0xffff82f72840>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Command index version or cloud profile is invalid or doesn't match the current command.
DEBUG: cli.azure.cli.core: Command index has been invalidated.
DEBUG: cli.azure.cli.core: No module found from index for '['storage', 'copy', '--debug']'
DEBUG: cli.azure.cli.core: Loading all modules and extensions
DEBUG: 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']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: acr 0.102 36 149
DEBUG: cli.azure.cli.core: acs 0.008 14 77
DEBUG: cli.azure.cli.core: advisor 0.000 3 6
DEBUG: cli.azure.cli.core: ams 0.002 22 100
DEBUG: cli.azure.cli.core: apim 0.002 14 69
DEBUG: cli.azure.cli.core: appconfig 0.002 9 47
DEBUG: cli.azure.cli.core: appservice 0.011 79 270
DEBUG: cli.azure.cli.core: aro 0.004 1 10
DEBUG: cli.azure.cli.core: backup 0.002 16 60
DEBUG: cli.azure.cli.core: batch 0.026 34 102
DEBUG: cli.azure.cli.core: batchai 0.001 10 30
DEBUG: cli.azure.cli.core: billing 0.006 20 53
DEBUG: cli.azure.cli.core: botservice 0.001 12 42
DEBUG: cli.azure.cli.core: cdn 0.071 8 50
DEBUG: cli.azure.cli.core: cloud 0.001 1 7
DEBUG: cli.azure.cli.core: cognitiveservices 0.001 10 33
DEBUG: cli.azure.cli.core: compute_recommender 0.001 1 1
DEBUG: cli.azure.cli.core: computefleet 0.004 1 1
DEBUG: cli.azure.cli.core: config 0.001 2 7
DEBUG: cli.azure.cli.core: configure 0.000 2 5
DEBUG: cli.azure.cli.core: consumption 0.006 8 9
DEBUG: cli.azure.cli.core: container 0.004 2 17
DEBUG: cli.azure.cli.core: containerapp 0.045 37 123
DEBUG: cli.azure.cli.core: cosmosdb 0.005 58 199
DEBUG: cli.azure.cli.core: databoxedge 0.003 5 28
DEBUG: cli.azure.cli.core: dls 0.001 6 36
DEBUG: cli.azure.cli.core: dms 0.001 3 22
DEBUG: cli.azure.cli.core: eventgrid 0.002 25 96
DEBUG: cli.azure.cli.core: eventhubs 0.003 13 20
DEBUG: cli.azure.cli.core: extension 0.000 1 7
DEBUG: cli.azure.cli.core: feedback 0.000 1 2
DEBUG: cli.azure.cli.core: find 0.000 1 1
DEBUG: cli.azure.cli.core: hdinsight 0.003 9 42
DEBUG: cli.azure.cli.core: identity 0.001 2 11
DEBUG: cli.azure.cli.core: interactive 0.000 1 1
DEBUG: cli.azure.cli.core: iot 0.050 19 82
DEBUG: cli.azure.cli.core: keyvault 0.006 20 113
DEBUG: cli.azure.cli.core: lab 0.015 9 29
DEBUG: cli.azure.cli.core: managedservices 0.005 3 8
DEBUG: cli.azure.cli.core: maps 0.001 5 13
DEBUG: cli.azure.cli.core: marketplaceordering 0.001 1 2
DEBUG: cli.azure.cli.core: monitor 0.266 17 61
DEBUG: cli.azure.cli.core: mysql 0.048 16 56
DEBUG: cli.azure.cli.core: netappfiles 0.019 8 17
DEBUG: cli.azure.cli.core: network 0.059 103 338
DEBUG: cli.azure.cli.core: policyinsights 0.005 9 17
DEBUG: cli.azure.cli.core: privatedns 0.008 14 60
DEBUG: cli.azure.cli.core: profile 0.001 2 8
DEBUG: cli.azure.cli.core: rdbms 0.035 50 208
DEBUG: cli.azure.cli.core: redis 0.001 7 38
DEBUG: cli.azure.cli.core: relay 0.010 7 8
DEBUG: cli.azure.cli.core: resource 0.006 52 232
DEBUG: cli.azure.cli.core: role 0.001 17 61
DEBUG: cli.azure.cli.core: search 0.006 7 19
DEBUG: cli.azure.cli.core: security 0.006 47 98
DEBUG: cli.azure.cli.core: servicebus 0.049 14 17
DEBUG: cli.azure.cli.core: serviceconnector 0.011 20 315
DEBUG: cli.azure.cli.core: servicefabric 0.006 27 80
DEBUG: cli.azure.cli.core: signalr 0.001 10 42
DEBUG: cli.azure.cli.core: sql 0.006 56 215
DEBUG: cli.azure.cli.core: sqlvm 0.014 4 20
DEBUG: cli.azure.cli.core: storage 0.018 59 273
DEBUG: cli.azure.cli.core: synapse 0.005 54 246
DEBUG: cli.azure.cli.core: util 0.000 3 7
DEBUG: cli.azure.cli.core: vm 0.020 58 233
DEBUG: cli.azure.cli.core: Total (65) 1.002 1185 4649
DEBUG: cli.azure.cli.core: Loaded 1171 groups, 4649 commands.
DEBUG: cli.azure.cli.core: Updated command index in 0.002 seconds.
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0xffff81d1ae80>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/root/.azure/commands/2025-01-09.21-07-22.storage_copy.9.log'.
INFO: az_command_data_logger: command args: storage copy --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.
DEBUG: cli.azure.cli.core.profiles._shared: Traceback (most recent call last): File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 656, in _get_attr op = getattr(op, part) ^^^^^^^^^^^^^^^^^ AttributeError: module 'azure.mgmt.storage.v2023_05_01.models' has no attribute 'ListKeyExpand'
DEBUG: cli.azure.cli.core.profiles._shared: Traceback (most recent call last): File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 656, in _get_attr op = getattr(op, part) ^^^^^^^^^^^^^^^^^ AttributeError: module 'azure.mgmt.storage.v2023_05_01.models' has no attribute 'CorsRuleAllowedMethodsItem'
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 76, in install_azcopy _urlretrieve(file_url, install_location) File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 224, in _urlretrieve req = urlopen(url) ^^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 515, in open response = self._open(req, data) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 532, in _open result = self._call_chain(self.handle_open, protocol, protocol + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain result = func(*args) ^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 1392, in https_open return self.do_open(http.client.HTTPSConnection, req, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/urllib/request.py", line 1347, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 733, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 725, in _run_job return cmd_copy.exception_handler(ex) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/init.py", line 430, in new_handler first(ex) File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/init.py", line 429, in new_handler raise ex File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(**command_args) ^^^^^^^^^^^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 15, in storage_copy azcopy = AzCopy() ^^^^^^^^ File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 54, in init self.install_azcopy(install_location) File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 80, in install_azcopy raise CLIError('Connection error while attempting to download azcopy {}. You could also install the ' knack.util.CLIError: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>)
ERROR: cli.azure.cli.core.azclierror: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>) ERROR: az_command_data_logger: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>) DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0xffff81d1b100>] INFO: az_command_data_logger: exit code: 1 INFO: cli.main: Command ran in 1.805 seconds (init: 0.482, invoke: 1.323) DEBUG: cli.azure.cli.core._profile: Failed to load installationId from AzureRmSurvey.json. [Errno 2] No such file or directory: '/root/.azure/AzureRmContextSettings.json' 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 3686 in cache file under /root/.azure/telemetry/20250109210723243 INFO: telemetry.main: Begin creating telemetry upload process. INFO: telemetry.process: Creating upload process: "/usr/bin/python3.12 /usr/lib/az/lib/python3.12/site-packages/azure/cli/telemetry/init.py /root/.azure /root/.azure/telemetry/20250109210723243" INFO: telemetry.process: Return from creating process 14 INFO: telemetry.main: Finish creating telemetry upload process.
Expected behavior
it should work
Environment Summary
azure-cli 2.52.0 *
core 2.52.0 * telemetry 1.1.0
Extensions: ml 2.20.0
Dependencies: msal 1.24.0b1 azure-mgmt-resource 23.1.0b2
Python location '/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/bin/python' Extensions directory '/Users/harshakethineni/.azure/cliextensions'
Python (Darwin) 3.10.13 (main, Aug 24 2023, 22:36:46) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Legal docs and information: aka.ms/AzureCliLegal
Additional context
No response
Thank you for opening this issue, we will look into it.
I think bumping https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py#L25 to a more recent version would work
Same thing is happening to me right now!!!! @hkethi002 @yonzhan
Run azure/[email protected] with: inlineScript: az storage blob sync -c '$web' -s 'public' --connection-string '***'
azcliversion: latest
Starting script execution via docker image mcr.microsoft.com/azure-cli:latest 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 WARNING: Azcopy not found, installing at /root/.azure/bin/azcopy ERROR: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>) Error: Error: az cli script failed. cleaning up container... MICROSOFT_AZURE_CLI_1736451680971_CONTAINER
Same thing is happening to me right now!!!! @hkethi002 @yonzhan
I managed to do a workaround by adding tdnf install azcopy -y to the start of my script I'm running in the container if that helps
Root Cause
Azure deprecated the previously Azure CDN (https://azureedge.net) and the Azure-CLI attempts to download the azcopy from CDN in case of not found locally
The previous address was built dynamically here and is exactly that which is not working anymore - checked doing this:
wget https://azcopyvnext.azureedge.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
The azure-cli module install should be updated to use the new url:
https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_{}_{}_{}.{}
You can confirm that approach works by doing this:
wget https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
@calvinhzy @evelyn-ys - Please open a PR and fix this, it could cause so much damage to many companies using azcopy inside azure-cli.
In this meanwhile, from our developer side, the best we can do is try to install azcopy manually where you need - like @hkethi002 suggest
@evelyn-ys @calvinhzy Can we please get an update when this is fixed. Im using Azure CLI and Azcopy through a github runner, theres no way for me to manually install it
This issue has broken some of our build pipelines that use the azure/cli@v2 action item as of around noon CST today. Would be nice to have this bumped in priority as it seems to be a relatively common issue that disrupts many pipelines globally.
This is happening even with the latest az cli version available as of today (2.67.0). This is happening to everyone using az cli that does not yet have a copy of the azcopy tool downloaded locally, and it is impacting automated deployments, as already mentioned by others here in the post.
Please, this is urgent since it cannot be even resolved by bumping your az cli installation to the latest version, so a fix for this is required as soon as possible as the impact is global.
Will get a fix out asap to install azcopy using the latest links here https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?tabs=dnf#download-the-azcopy-portable-binary In the mean time please manually install Azcopy before running azcopy related commands. Sorry for the issue.
Here's an example of installing azcopy in a running container
docker run -it --rm mcr.microsoft.com/azure-cli:2.64.0-amd64
tdnf install tar-1.34-3.cm2.x86_64 -y;
# Using curl in mcr.microsoft.com/azure-cli:2.64.0-amd64 and newer
curl -O https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz;
mkdir /root/.azure;
mkdir /root/.azure/bin;
tar -xf azcopy_linux_amd64_10.13.0.tar.gz --strip-components=1 -C /root/.azure/bin;
# now I am able to use az storage copy
The same problem:
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 WARNING: Azcopy not found, installing at /root/.azure/bin/azcopy ERROR: Connection error while attempting to download azcopy 10.13.0. You could also install the specified azcopy version to /root/.azure/bin manually. (<urlopen error [Errno -2] Name or service not known>) Cleaning up project directory and file based variables 00:00 ERROR: Job failed: command terminated with exit code 1
@akvarpop do you mean that you tried installing azcopy it via downloading the gz file like above but still getting error?
@shurick81 Nope) it's when i run pipelines. I will be waiting Azure fix till Monday) if no i will try your solution Thanks!
@shurick81 you can also just run (assuming you are running in an Azure Linux / Mariner)
tdnf install -y azcopy
This did the trick for us.
Will get a fix out asap to install azcopy using the latest links here https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?tabs=dnf#download-the-azcopy-portable-binary In the mean time please manually install Azcopy before running azcopy related commands. Sorry for the issue.
Hi @calvinhzy , FYI: Please be aware that azcopy versions >= 10.27.0 potentially have memory leak issue ( https://github.com/Azure/azure-storage-azcopy/issues/2855 ).
@sebader thanks, that is an option. It is also possible to install as old azcopy version as 10.15.0 via this:
tdnf install azcopy-10.15.0
However, I could not find a way to install the same azcopy version as az cli used to install, which is 10.13.0, using tdnf. That is why I had to come up with more complicated solution.
I asked github copilot to do it for my github actions workflow and it did it correctly on the second try
tdnf azcopy worked for me as well. Here's the snippet when using v1 in GitHub Actions.
- name: Upload to blob storage
uses: azure/CLI@v1
with:
azcliversion: 2.67.0
# azcopy workadound https://github.com/Azure/azure-cli/issues/30635
inlineScript: |
tdnf install -y azcopy;
# YOUR SCRIPT
@ep-ss-2021 good point regarding unstable latest versions, I might still pin it to 10.13.0 and if the user needs a newer version, they can install manually.
With the net8 runtime image as a base i was able to use this:
RUN curl -L https://aka.ms/downloadazcopy-v10-linux -o downloadazcopy-v10-linux
RUN tar -xvf downloadazcopy-v10-linux
# Move AzCopy
RUN rm -f /usr/bin/azcopy
RUN cp ./azcopy_linux_amd64_*/azcopy /usr/bin/
RUN chmod 755 /usr/bin/azcopy
# Clean the kitchen
RUN rm -f downloadazcopy-v10-linux
RUN rm -rf ./azcopy_linux_amd64_*/