AzCopy Download is Broken Due to Dead MSFT Link
Describe the bug
In the AzCopy v10.32.0 release notes (link), they note that they intend to stop support for AzCopy download URLs hosted via Azure Front Door. We noticed today that one of our pipelines is failing and traced the cause back to this. Not sure if you can get them to change their mind, but I'm assuming not.
There is experience in Azure CLI with overcoming this issue once before (see #30640), and there is now even a back up URL tried as of #30712. Currently, the backup URLs all point to the Front Door URL, so they are also failing.
Can the install_azcopy function please be updated (permalink to current tip of dev)?
It would also be nice if you could change the existing aka.ms URLs to point to the new hosting location of AzCopy, otherwise there is no currently available version of Azure CLI that can self-download AzCopy.
Workaround
As noted in the original issue the first time download of AzCopy broke (#30625), if azcopy is available on the PATH (or, presumably, in the current directory of the process running az), and it is at least version 10.13.0 (this is defined here, and here), then no download would be attempted. So, the workaround would be to install AzCopy earlier in your pipeline, if at all possible (original comment).
Related command
N/A
Errors
N/A
Issue script & Debug output
N/A
Expected behavior
N/A
Environment Summary
N/A
Additional context
Sorry, I would love to add more details, but I'm submitting after hours as I don't use GitHub at work. Also, this one is really simple to reproduce: just go to the existing link under https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/.
Thank you for opening this issue, we will look into it.
I confirm this is happening to me as well. As already said, this is affecting all versions of the AZ CLI, and there is not a chance of self-download of AzCopy now, so it is a global issue currently. Please, those links should be working since any new usages of the az CLI commands involved for this kind of operation, like it usually occurs with the pipelines, will not stop failing because of this, and this is a matter of urgency depending on each scenario.
Same problem happens in our deployment pipeline. We are currently blocked rolling out new features. Any ideas of a work around?
Steps to reproduce: docker run -it mcr.microsoft.com/azure-cli
root [ / ]# az storage blob sync --source ./someFolder --container "someContainer" --account-name someAccountName --auth-mode key --account-key "someKey" --delete-destination false
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
Azcopy not found, installing at /root/.azure/bin/azcopy
There is an error downloading from the url: https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
There is an error downloading from the url: https://aka.ms/InstallAzCopyForCLILinux
Downloading AzCopy from None
The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute 'timeout'
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/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 505, in open
req.timeout = timeout
^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'timeout'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
@ichesa, @ivthentschel
I've edited my original report to include the workaround. It is the same as last time this happened. You need to make azcopy available beforehand to avoid the need for az to attempt to install it.
In my situation, I was able to put azcopy.exe in the root of my repository and it was detected by az. We have a simple pipeline, though... if yours changes the working directory (e.g., moves into a subfolder), you may need to prepend the build directory to the PATH, too, if taking this approach.
Facing the same issue
Running it without exclude include filter
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
WARNING: There is an error downloading from the url: https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
WARNING: Downloading AzCopy from https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: IncompleteRead(8388175 bytes read, 3487837 more expected)
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 734, 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 726, 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 120, 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 52, 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 81, 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 233, in _urlretrieve
compressedFile = io.BytesIO(req.read())
^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 495, in read
s = self._safe_read(self.length)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 642, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(8388175 bytes read, 3487837 more expected)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
Gonna try the workaround to fix this by installing azcopy manually.
The changes in #32868 mean that future versions of the CLI will always download the latest AzCopy. This is a change from the previous behaviour, where you downloaded the version defined by the AZCOPY_VERSION variable (although, this still acts as the minimum required version which indicates if download will be required).
Also, due to the redirect happening on the download URL, this does not fix download for previous versions (the final URL does not end with zip or gz). Can you please confirm the intention is to require upgrade to v2.85.0 (i.e., we cannot get the old aka.ms links to redirect to a compatible URL)?
It seems the code previously was not compatible with using download links in the github release as the redirect link. I will continue to look for alternative ways to fix it so it is not required to update to the new CLI version. As for the azcopy version, it has been asked in other issues that the latest version is preferred as the default as it has the latest features, bugfixes from the AzCopy tool. Maybe I will add an env variable so the user can manually specify the desired version? Let me know if that is preferred.
Yeah, unfortunately I don't think there is an easy way to fix the download for currently availables versions. You could adapt this minimal example (i.e., add error handling and status checks) if you wanted to continue to use the https://aka.ms/InstallAzCopyForCLIWindowsX64 URLs in future versions, though:
def get_url_filename(uri):
import urllib.request, urllib.parse, os
r = urllib.request.urlopen(uri)
return r.info().get_filename() or os.path.basename(urllib.parse.urlsplit(r.url).path)
As for my concerns with the version, I consider it to be somewhat analogous to pinning dependencies. There is a slight risk that a future version of AzCopy might change the command syntax. Or that there is some other issue in the latest available version (e.g., memory leak).
Either way, it is convenient to me that Azure CLI will source AzCopy automatically, but, relying on this has caused headaches a few times now. It would be nice if they came bundled at install time, maybe?
We're seeing this as well, its really convenient that Azure CLI will source AzCopy as it does not require the pipeline to be aware of what agent it is running on (Windows vs Linux). The PR looks like it's scheduled for the April release of the toolset is that correct?
As mentioned above there is concern with it downloading the latest version of AzCopy, for our purposes we were never concerned with taking the latest. It'd be interesting to see if there was any telemetry on how often that override was actually used.
In the interim the work around works (installing AzCopy manually).