通过 AzCopy 操作 Azure 存储
相关概念
** Azcopy **: AzCopy 是一个高性能的命令行实用程序,用于将数据上载、复制到 Azure 二进制存储(Blob)、文件存储(File)和表存储(Table)以及从其中下载和复制数据。如何下载,安装以及更多的 AzCopy 命令请参见: AzCopy 命令行实用程序入门。
详细步骤
打开 Azure Command Prompt
使用
cd %ProgramFiles(x86)%\Microsoft SDKs\Azure\AzCopy
定位到 AzCopy 的安装目录, 64-bit Window 为%ProgramFiles(x86)%\Microsoft SDKs\Azure\
,32-bit Windows 为%ProgramFiles%\Microsoft SDKs\Azure\
使用下面的命令即可做对应的操作。
常用命令
上传文件到 Blob storage:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.chinacloudapi.cn/mycontainer /DestKey:key /Pattern:abc.txt
下载文件到文件系统:
AzCopy /Source:https://myaccount.blob.core.chinacloudapi.cn/mycontainer /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt
在同一个 storage 账号里面拷贝文件:
AzCopy /Source:https://myaccount.blob.core.chinacloudapi.cn/mycontainer1 /Dest:https://myaccount.blob.core.chinacloudapi.cn/mycontainer2 /SourceKey:key /DestKey:key /Pattern:abc.txt
在不同的 storage 账号里面拷贝文件:
AzCopy /Source:https://sourceaccount.blob.core.chinacloudapi.cn/mycontainer1 /Dest:https://destaccount.blob.core.chinacloudapi.cn/mycontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.txt
上传文件到 storage 下新建文件夹:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.chinacloudapi.cn/mynewcontainer /DestKey:key /Pattern:abc.txt
递归方式上传文件夹下所有内容到 storage:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.chinacloudapi.cn/mycontainer /DestKey:key /S
递归查找匹配的文件并上传到 storage:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.chinacloudapi.cn/mycontainer /DestKey:key /Pattern:a* /S
拷贝 Blob 及其快照到另一个 storage:
AzCopy /Source:https://sourceaccount.blob.core.chinacloudapi.cn/mycontainer1 /Dest:https://destaccount.blob.core.chinacloudapi.cn/mycontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.txt /Snapshot