azcopy removeazcopy remove
从 Azure 存储帐户中删除 blob 或文件。Delete blobs or files from an Azure storage account.
摘要Synopsis
azcopy remove [resourceURL] [flags]
相关概念性文章Related conceptual articles
- AzCopy 入门Get started with AzCopy
- 使用 AzCopy 和 Blob 存储传输数据Transfer data with AzCopy and Blob storage
- 使用 AzCopy 和文件存储传输数据Transfer data with AzCopy and file storage
- 对 AzCopy 进行配置、优化和故障排除Configure, optimize, and troubleshoot AzCopy
示例Examples
使用 SAS 令牌删除单个 Blob:Remove a single blob by using a SAS token:
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/blob]?[SAS]"
使用 SAS 令牌删除整个虚拟目录:Remove an entire virtual directory by using a SAS token:
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/directory]?[SAS]" --recursive=true
仅删除虚拟目录内的 blob,但不删除任何子目录或这些子目录中的 blob:Remove only the blobs inside of a virtual directory, but don't remove any subdirectories or blobs within those subdirectories:
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/virtual/dir]" --recursive=false
删除虚拟目录中的一部分 blob(例如:仅删除 jpg 和 pdf 文件,或者删除名为“exactName
”的 blob):Remove a subset of blobs in a virtual directory (For example: remove only jpg and pdf files, or if the blob name is exactName
):
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/directory]?[SAS]" --recursive=true --include-pattern="*.jpg;*.pdf;exactName"
删除整个虚拟目录,但从范围中排除某些 blob(例如:以 foo 开头或以 bar 结尾的每个 blob):Remove an entire virtual directory but exclude certain blobs from the scope (For example: every blob that starts with foo or ends with bar):
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/directory]?[SAS]" --recursive=true --exclude-pattern="foo*;*bar"
删除特定 blob 和虚拟目录,方法是将其相对路径(非 URL 编码)置于文件中:Remove specific blobs and virtual directories by putting their relative paths (NOT URL-encoded) in a file:
azcopy rm "https://[account].blob.core.chinacloudapi.cn/[container]/[path/to/parent/dir]" --recursive=true --list-of-files=/usr/bar/list.txt
- file content:
dir1/dir2
blob1
blob2
从采用分层命名空间的 Blob 存储帐户中删除单个文件(不支持 include/exclude):Remove a single file from a Blob Storage account that has a hierarchical namespace (include/exclude not supported):
azcopy rm "https://[account].dfs.core.chinacloudapi.cn/[container]/[path/to/file]?[SAS]"
从采用分层命名空间的 Blob 存储帐户中删除单个目录(不支持 include/exclude):Remove a single directory from a Blob Storage account that has a hierarchical namespace (include/exclude not supported):
azcopy rm "https://[account].dfs.core.chinacloudapi.cn/[container]/[path/to/directory]?[SAS]"
选项Options
--delete-snapshots 字符串:如果 blob 有快照,删除操作默认将失败。--delete-snapshots string By default, the delete operation fails if a blob has snapshots. 可指定“include
”以删除根 blob 及其所有快照;也可指定“only
”以仅删除快照,但保留根 blob。Specify include
to remove the root blob and all its snapshots; alternatively specify only
to remove only the snapshots but keep the root blob.
--exclude-path 字符串:删除时排除这些路径。--exclude-path string Exclude these paths when removing. 此选项不支持通配符 (*)。This option does not support wildcard characters (*). 检查相对路径前缀。Checks relative path prefix. 例如:myFolder;myFolder/subDirName/file.pdf
For example: myFolder;myFolder/subDirName/file.pdf
--exclude-pattern 字符串 排除名称与模式列表相匹配的文件。--exclude-pattern string Exclude files where the name matches the pattern list. 例如:*.jpg
;*.pdf
;exactName
For example: *.jpg
;*.pdf
;exactName
--force-if-read-only:删除 Azure 文件存储文件或文件夹时,即使现有对象已设置其只读属性,也会强制执行删除操作。--force-if-read-only When deleting an Azure Files file or folder, force the deletion to work even if the existing object is has its read-only attribute set.
--help:用于获取删除帮助。--help help for remove.
--include-path 字符串:删除时仅包括这些路径。--include-path string Include only these paths when removing. 此选项不支持通配符 (*)。This option does not support wildcard characters (*). 检查相对路径前缀。Checks relative path prefix. 例如:myFolder;myFolder/subDirName/file.pdf
For example: myFolder;myFolder/subDirName/file.pdf
--include-pattern 字符串:仅包括名称与模式列表相匹配的文件。--include-pattern string Include only files where the name matches the pattern list. 例如: .jpg
; .pdf
;exactName
For example: .jpg
;.pdf
;exactName
--list-of-files 字符串:定义要删除的文件和目录列表所在文件的位置。--list-of-files string Defines the location of a file, which contains the list of files and directories to be deleted. 相对路径应由换行符分隔,路径不应进行 URL 编码。The relative paths should be delimited by line breaks, and the paths should NOT be URL-encoded.
--log-level 字符串:定义日志文件的日志详细程度。--log-level string Define the log verbosity for the log file. 可用级别包括:INFO
(所有请求/响应)、WARNING
(缓慢的响应)、ERROR
(仅失败的请求)和 NONE
(无输出日志)。Available levels include: INFO
(all requests/responses), WARNING
(slow responses), ERROR
(only failed requests), and NONE
(no output logs). (默认值为 INFO
)(默认值为 INFO
)(default INFO
) (default INFO
)
--recursive:在目录之间同步时,以递归方式查看子目录。--recursive Look into subdirectories recursively when syncing between directories.
从父命令继承的选项Options inherited from parent commands
选项Option | 说明Description |
---|---|
--cap-mbps float--cap-mbps float | 以兆位/秒为单位限制传输速率。Caps the transfer rate, in megabits per second. 瞬间吞吐量可能与上限略有不同。Moment-by-moment throughput might vary slightly from the cap. 如果此选项设置为零,或者省略,则吞吐量不受限制。If this option is set to zero, or it is omitted, the throughput isn't capped. |
--output-type string--output-type string | 命令输出的格式。Format of the command's output. 选项包括:text、json。The choices include: text, json. 默认值为“text”。The default value is "text". |
--trusted-microsoft-suffixes 字符串--trusted-microsoft-suffixes string | 指定可在其中发送 Azure Active Directory 登录令牌的其他域后缀。Specifies additional domain suffixes where Azure Active Directory login tokens may be sent. 默认值为“.core.windows.net;.core.chinacloudapi.cn;.core.cloudapi.de;.core.usgovcloudapi.net” 。The default is '.core.windows.net;.core.chinacloudapi.cn;.core.cloudapi.de;.core.usgovcloudapi.net'. 此处列出的任何内容都会添加到默认值。Any listed here are added to the default. 为安全起见,应只在此处放置 Azure 域。For security, you should only put Azure domains here. 用分号分隔多个条目。Separate multiple entries with semi-colons. |