Support renaming files in directories in `az storage`
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Related command**
`az storage file` and `az storage directory`
**Is your feature request related to a problem? Please describe.**
The missing `rename` operation is very common and would make for a great feature that completes the rest of the commands.
**Describe the solution you'd like**
The [`az storage file`](https://learn.microsoft.com/en-us/cli/azure/storage/file?view=azure-cli-latest) and [`az storage directory`](https://learn.microsoft.com/en-us/cli/azure/storage/directory?view=azure-cli-latest) utilities should include a `rename` operation.
**Describe alternatives you've considered**
The alternatives are to either:
* Using the REST API which provides [`Rename File`](https://learn.microsoft.com/en-us/rest/api/storageservices/rename-file) and [`Rename Directory`](https://learn.microsoft.com/en-us/rest/api/storageservices/rename-directory).
* Setting up Azure PowerShell which provides [`Rename-AzStorageFile`](https://learn.microsoft.com/en-us/powershell/module/az.storage/rename-azstoragefile?view=azps-12.5.0) and [`Rename-AzStorageDirectory`](https://learn.microsoft.com/en-us/powershell/module/az.storage/rename-azstoragedirectory?view=azps-12.5.0).
**Additional context**
Renaming a directory through the REST API is much less convenient than any of the `storage` commands:
```sh
az rest --method put \
--headers "{ \
\"x-ms-version\": \"2024-11-04\", \
\"x-ms-file-rename-source\": \"$SOURCE_DIR\", \
\"x-ms-file-request-intent\": \"backup\" }" \
--url "$TARGET_DIR"'?restype=directory&comp=rename' \
--resource "$SHARE_URL"
```
Contributor guide
Assessment
This issue has not been assessed yet.