Azure CLI ignores locally installed azcopy if version is 10.31.0~preview.1
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
I have installed Azure CLI 2.71.0 and azcopy `10.31.0~preview.1`. When I run the sync command I see Azure CLI ignores locally installed azcopy with version `10.31.0~preview.1` and downloads the old one `10.13`, which doesn't have argument `--compare-hash`.
### Related command
```
az storage blob sync `
-c $Container `
-s $workDir `
--account-name $StorageAccountName `
--auth-mode login `
-d "$dir/" `
-- --compare-hash MD5
```
### Errors
```
WARNING: You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'
14:04:02 Az Cli version: azure-cli 2.71.0 * core 2.71.0 * telemetry 1.1.0 Dependencies: msal 1.31.2b1 azure-mgmt-resource 23.1.1 Python location '/opt/az/bin/python3' Config directory '/home/admin/.azure' Extensions directory '/home/admin/.azure/cliextensions' Python (Linux) 3.12.8 (main, Mar 25 2025, 10:55:23) [GCC 13.3.0] Legal docs and information: aka.ms/AzureCliLegal
14:04:03 WARNING: This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
14:04:03 WARNING: Positional argument '' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
14:04:08 WARNING: Azcopy not found, installing at /home/admin/.azure/bin/azcopy
14:04:08 WARNING: Downloading AzCopy from https://azcopyvnext-awgzd8g7aagqhzhe.b02.azurefd.net/release20211027/azcopy_linux_amd64_10.13.0.tar.gz
14:04:08 WARNING: Azcopy command: []
14:04:08
14:04:08 unknown flag: --compare-hash
```
### Issue script & Debug output
Looks like the used "packaging.version" package used in [this](https://github.com/Azure/azure-cli/blob/9a57ac32583d036e4311497ce5029fafceb9aba3/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py#L45) code block doesn't support this version format `10.31.0~preview.1`:
```
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/packaging/version.py", line 54, in parse
return Version(version)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/packaging/version.py", line 200, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '10.31.0~preview.1'
```
### Expected behavior
Version (even preview) is correctly resolved, and locally installed azcopy is used instead of downloading the new one (older version).
### Environment Summary
azure-cli 2.71.0 *
core 2.71.0 *
telemetry 1.1.0
Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1
Python location '/opt/az/bin/python3'
Config directory '/home/admin/.azure'
Extensions directory '/home/admin/.azure/cliextensions'
Python (Linux) 3.12.8 (main, Mar 25 2025, 10:55:23) [GCC 13.3.0]
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.