Misbehaving pattern option in azure storage blob download-batch command when there is a local directory with the same name as that of the blob being used in command
See original GitHub issueDescribe the bug I have a blob in the container. I have a local directory which has the same name. When I run download-batch command with pattern option as “blob_name/*”, it is expanding the command options with the files in the local directory and failing.
To Reproduce
Create a directory locally test_pattern with multiple files file1 and file2 in it.
Upload a blob with the same name test_pattern.
Then try to download using the following command with pattern option from the path where local directory exists.
az storage blob download-batch -d . --pattern test_pattern/* -s <container>
Error: cli.azure.cli.core.parser : az: error: unrecognized arguments: test_pattern/file2 az: error: unrecognized arguments: test_pattern/file2
Debug message: Command arguments: [‘storage’, ‘blob’, ‘download-batch’, ‘-d’, ‘.’, ‘–pattern’, ’ test_pattern/file1’, ’ test_pattern/file2’, ‘-s’, ‘mlebarstoragecontainer’, ‘–debug’]
Expected behavior It should not care about the local directory, it should just find a blob with the given name in the container and download locally or throw a proper warning/error.
Environment summary
Install Method: pip CLI version: azure-cli: 2.0.60 * storage: 2.4.2 OS version: Ubuntu Docker Container Shell Type: bash
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
I had the same issue. @raviteja22 was on the right track that the issue is bash expands the glob pattern and passes that on to az cli – but the issue doesn’t have anything to do with blob/directory names. AZ CLI expects to see the glob pattern, but only see the expanded filenames that fit the pattern instead. Adding a backslash before the glob (maybe quotes would work as well?) fixes the problem. Something like:
Thanks, you helped me solve my issue.