如何使用az storage fs directory下载Azure存储目录内容?求Windows示例
解决Azure CLI目录下载命令弃用问题及操作示例
核心说明
az storage fs directory download中的--file-system参数,直接填写你的Blob容器名称即可(该命令兼容普通Blob存储容器和ADLS Gen2文件系统)。
下载操作示例(Windows环境)
假设:
- 存储账户名:
mystorageaccount - Blob容器名:
mycontainer - 容器内要下载的目录路径:
data/reports/2024 - Windows本地目标路径:
D:\downloads\reports
以下是三种常用认证方式的命令示例:
1. 存储账户密钥认证
az storage fs directory download --account-name mystorageaccount --account-key "你的存储账户密钥" --file-system mycontainer --path "data/reports/2024" --destination "D:\downloads\reports" --recursive
2. SAS令牌认证
az storage fs directory download --account-name mystorageaccount --sas-token "你的SAS令牌" --file-system mycontainer --path "data/reports/2024" --destination "D:\downloads\reports" --recursive
3. Azure AD登录认证(已通过az login登录)
az storage fs directory download --account-name mystorageaccount --file-system mycontainer --path "data/reports/2024" --destination "D:\downloads\reports" --recursive
关键注意事项
- 必须添加
--recursive参数,否则只会创建空目录,不会下载目录内的文件和子目录。 - Windows路径使用反斜杠
\,需用双引号包裹避免解析错误。 - 若使用旧版未启用分层命名空间的存储账户,该命令依然有效,无需额外配置。
- 确保Azure CLI为最新版本,可通过
az upgrade命令升级。
内容的提问来源于stack exchange,提问作者noobie
相关产品推荐
相关产品推荐

