Linux 的 AzCopy 上传文件

AzCopy upload file for Linux

我正在尝试使用 Linux 的 AzCopy 从我的 Ubuntu 机器上传示例文件到 Azure,但无论 permission/ownership 我更改为什么,我都会收到以下错误.

$ azcopy     --source ../my_pub     --destination https://account-name.blob.core.windows.net/mycontainer     --dest-key account-key    
Incomplete operation with same command line detected at the journal directory "/home/jmis/Microsoft/Azure/AzCopy", do you want to resume the operation? Choose Yes to resume, choose No to overwrite the journal to start a new operation. (Yes/No) Yes
[2017/11/18 22:06:24][ERROR] Error parsing source location "../my_pub": Failed to enumerate directory /home/jmis/my_pub/ with file pattern *. Cannot find the path '/home/jmis/my_pub/'.

我在互联网上搜索以寻找解决方案,但运气不佳,我最终在这里提出了一个问题。

尽管 AzCopy 在 Linux 方面存在问题,但我可以使用 Azure CLI 无缝执行上述操作。 Azure docs 上列出的以下代码帮助我做到了:

#!/bin/bash
# A simple Azure Storage example script

export AZURE_STORAGE_ACCOUNT=<storage_account_name>
export AZURE_STORAGE_ACCESS_KEY=<storage_account_key>

export container_name=<container_name>
export blob_name=<blob_name>
export file_to_upload=<file_to_upload>
export destination_file=<destination_file>

echo "Creating the container..."
az storage container create --name $container_name

echo "Uploading the file..."
az storage blob upload --container-name $container_name --file $file_to_upload --name $blob_name

echo "Listing the blobs..."
az storage blob list --container-name $container_name --output table

echo "Downloading the file..."
az storage blob download --container-name $container_name --name $blob_name --file $destination_file --output table

echo "Done"

展望未来,我将使用 Cool Azure CLI,它与 Linux 兼容且也很简单。

我们可以使用此脚本通过 Azcopy(Linux) 上传 单个 文件:

azcopy \
    --source /mnt/myfiles \
    --destination https://myaccount.file.core.windows.net/myfileshare/ \
    --dest-key <key> \
    --include abc.txt

使用--include指定要上传的文件,这里有一个例子,请查看:

root@jasonubuntu:/jason# pwd
/jason
root@jasonubuntu:/jason# ls
test1


root@jasonubuntu:/jason# azcopy --source /jason/ --destination https://jasondisk3.blob.core.windows.net/jasonvm/ --dest-key m+kQwLuQZiI3LMoMTyAI8K40gkOD+ZaT9HUL3AgVr2KpOUdqTD/AG2j+TPHBpttq5hXRmTaQ== --recursive  --include test1
Finished 1 of total 1 file(s).                                                                                                                                                                                                 
[2017/11/20 07:45:57] Transfer summary:                                                                                                                                                                                        
-----------------
Total files transferred: 1
Transfer successfully:   1
Transfer skipped:        0
Transfer failed:         0
Elapsed time:            00.00:00:02
root@jasonubuntu:/jason# 

有关 Linux 上 Azcopy 的更多信息,请参阅此 link