Azure / Azure/azure-cli

Copy batch only files in directory but not directory itself

Open
#17,203 1 comment 0 reactions 1 assignee Assigned to @evelyn-ys View on GitHub
act-codegen-extensibility-squad feature-request Storage
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

It would be useful to be able to do a "flat" batch copy, and not include the directory itself. For instance:

```
az storage blob copy start-batch --connection-string $RELEASE_STORAGE_ACCOUNT_CONNECTION_STRING --destination-path batch --destination-container function-artifacts --source-container function-artifacts --pattern 1180/*.zip
[
"https://storage.blob.core.windows.net/function-artifacts/batch/1180/xx.zip",
"https://storage.blob.core.windows.net/function-artifacts/batch/1180/xx.zip",
"https://storage.blob.core.windows.net/function-artifacts/batch/1180/xx.zip"
]
```

I would expect this instead:
```
path batch --destination-container function-artifacts --source-container function-artifacts --pattern 1180/*.zip
[
"https://storage.blob.core.windows.net/function-artifacts/batch/xx.zip",
"https://storage.blob.core.windows.net/function-artifacts/batch/xx.zip",
"https://storage.blob.core.windows.net/function-artifacts/batch/xx.zip"
]
```

It feels counter intuitive to include the folder when I explicitly state that I want the zip files within that folder. If I on the other hand would have specified my pattern as just `*.zip`, then including the folders that contain zip files make more sense.

Compare this to the behavior of upload-batch:

```
az storage blob upload-batch --connection-string $RELEASE_STORAGE_ACCOUNT_CONNECTION_STRING --destination function-artifacts --destination-path batch --source dist --pattern *.zip
Finished[#############################################################] 100.0000%
[
{
"Blob": "https://storage.blob.core.windows.net/function-artifacts/batch/xx.zip",
"Last Modified": "2021-03-04T10:07:02+00:00",
"Type": "application/zip",
"eTag": "\"0x8D8DEF542116BAD\""
}
]
```
This only includes the files in my chosen directory, not the dist directory itself.

Also compare the behavior of copy batch to the cp command:
```
$ cp dist/*.zip tmp/
$ ls -l tmp/
total 9676
-rw-r--r-- 1 xx xx 9905440 mar 4 11:14 generic.zip
```

If this is possible already I'd like to know how to achieve this behavior.

My versions:
```
$ az --version
azure-cli 2.16.0 *

core 2.16.0 *
telemetry 1.0.6

Python location '/opt/az/bin/python3'
Extensions directory '/home/johan/.azure/cliextensions'

Python (Linux) 3.6.10 (default, Dec 4 2020, 12:35:15)
[GCC 9.2.1 20191008]

```

And in our pipelines we use the latest image of `mcr.microsoft.com/azure-cli`

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 8b4e73a9-187f-ad77-3f22-52e7c3edd149
* Version Independent ID: e58b4f05-7bbc-fcb0-ee55-571ee68bd3e7
* Content: [az storage blob copy](https://docs.microsoft.com/en-us/cli/azure/storage/blob/copy?view=azure-cli-latest#az_storage_blob_copy_start_batch)
* Content Source: [latest/docs-ref-autogen/storage/blob/copy.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/latest/docs-ref-autogen/storage/blob/copy.yml)
* Service: **storage**
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.