Command Name
az storage blob sync
Errors:
The command failed with an unexpected error. Here is the traceback:
File is not a zip file
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 560, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 618, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 609, in _run_job
cmd_copy.exception_handler(ex)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/__init__.py", line 240, in new_handler
handler(ex)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/__init__.py", line 183, in handler
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 588, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 297, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 461, in default_command_handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 36, in storage_blob_sync
azcopy = _azcopy_blob_client(cmd, client)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 54, in _azcopy_blob_client
return AzCopy(creds=blob_client_auth_for_azcopy(cmd, client))
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 48, in __init__
_urlretrieve(file_url, install_location)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 187, in _urlretrieve
zip_file = zipfile.ZipFile(io.BytesIO(req.read()))
File "/opt/az/lib/python3.6/zipfile.py", line 1108, in __init__
self._RealGetContents()
File "/opt/az/lib/python3.6/zipfile.py", line 1175, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
az storage blob sync -c {} --account-name {} -s {} -d {}Files in the local source path are transferred to the destination path in the container
Linux-4.4.0-142-generic-x86_64-with-debian-buster-sid
Python 3.6.5
Shell: bash
azure-cli 2.0.65
Tested using the mcr.microsoft.com/azure-cli docker image, and using an ubuntu 18.04 docker with azure-cli package installed from the packages.microsoft.com apt repo.
@limingu we should catch this exception and handle it properly.
@richardmansfield it seems like your source file should be a zip file but it is not...
I'm not sure why it thinks my source file should be a zip file, does az
storage blob sync command only work on zip files? I thought it would sync a
whole folder. It'd be good to clear this up in the documentation; "az
storage blob sync --help" doesn't mention zip files at all.
On Sat, 1 Jun 2019 at 05:40, adewaleo notifications@github.com wrote:
@limingu https://github.com/limingu we should catch this exception and
handle it properly.@richardmansfield https://github.com/richardmansfield it seems like
your source file should be a zip file but it is not...—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-cli/issues/9525?email_source=notifications&email_token=AACXXTGZLJRDOMB7NGHUQOLPYFPHXA5CNFSM4HRNICYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWV4Z2Y#issuecomment-497798379,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACXXTB6KZWFFGD5HB6VG4LPYFPHXANCNFSM4HRNICYA
.
It's not that az storage blob sync only works with zip files. It's that it downloads azcopy and expects that download to be a zip file (that it then extracts azcopy from).
For Windows, it downloads https://azcopyvnext.azureedge.net/release20190423/azcopy_windows_amd64_10.1.0.zip which is probably a zip file (I didn't check).
For Linux, it downloads https://azcopyvnext.azureedge.net/release20190423/azcopy_linux_amd64_10.1.0.tar.gz which exists but is obviously not a zip file. So it's a bug in _urlretrieve that it only tries to parse the download as a zip regardless of platform.
This is bug for Linux. I will fix it soon.
Most helpful comment
This is bug for Linux. I will fix it soon.