AzCopy - 如何使用 SAS 将单个文件上传到容器
AzCopy - how to upload single file to a container using SAS
我有一个用于容器的 SAS(只写,但我也尝试读-写-列表)。我需要将单个文件上传到该容器。所以我为此使用 AzCopy:
AzCopy /Source:./ /Dest:https://account.blob.core.windows.net/container/?sv=2018-03-28&si=write&sr=c&sig=****** /Pattern:somefile.ext /V:./AzCopy.log
我尝试了另一个版本:
AzCopy /Source:somefile.ext /Dest:https://account.blob.core.windows.net/container/somefile.ext /DestSAS:******
但这也不管用。
而且我尝试了两个 AzCopy 版本 - 7.1.3 和 8.1!我还应该尝试什么?
顺便说一句,使用 Powershell 它就像一个魅力,具有相同的 SAS 令牌!
Windows 10 个最新。
更新
日志(在完全不同的机器上制作):
[2019.03.22 06:39:41.551+03:00] >>>>>>>>>>>>>>>> [2019.03.22
06:39:41.561+03:00][VERBOSE] Finished: 0 file(s), 0 B; Average Speed:0
B/s. [2019.03.22 06:39:41.569+03:00][VERBOSE] 8.1.0 : AzCopy
/Source:somefile.ext
/Dest:https://account.blob.core.windows.net/korch/somefile.ext
/DestSAS:****** /V:./AzCopy with SAS.log [2019.03.22
06:39:41.589+03:00][ERROR] An error occurred while reading the restart
journal from "C:\Users\user\AppData\Local\Microsoft\Azure\AzCopy".
Detailed error: Error parsing the journal file: Journal file was
generated by a different version of AzCopy. [2019.03.22
06:39:43.175+03:00][VERBOSE] [PROMPT] Do you want to overwrite the
journal to start a new operation? Choose Yes to overwrite, choose No
to cancel current operation. (Yes/No) : Y [2019.03.22
06:39:43.230+03:00][VERBOSE] Attempt to parse address 'somefile.ext'
to a directory as a candidate location succeeded. [2019.03.22
06:39:43.232+03:00][VERBOSE] Attempt to parse address 'somefile.ext'
to a single file as a candidate location succeeded. [2019.03.22
06:39:43.239+03:00][VERBOSE] Source is interpreted as a Local file:
G:\somefile.ext. [2019.03.22 06:39:43.260+03:00][VERBOSE] Attempt to
parse address
'https://account.blob.core.windows.net/korch/somefile.ext' to a
directory as a candidate location succeeded. [2019.03.22
06:39:43.269+03:00][VERBOSE] Attempt to parse address
'https://account.blob.core.windows.net/korch/somefile.ext' to a single
file as a candidate location succeeded. [2019.03.22
06:39:43.270+03:00][VERBOSE] Interpreting destination as a single file
as the provided source is a single file. [2019.03.22
06:39:43.271+03:00][VERBOSE] Destination is interpreted as a Cloud
blob: https://account.blob.core.windows.net/korch/somefile.ext.
[2019.03.22 06:39:43.942+03:00][VERBOSE] Start transfer:
G:\somefile.ext =>
https://account.blob.core.windows.net/korch/somefile.ext [2019.03.22
06:39:44.149+03:00][VERBOSE] Transfer FAILED: G:\somefile.ext =>
https://account.blob.core.windows.net/korch/somefile.ext. [2019.03.22
06:39:44.158+03:00][ERROR] An unknown error occurred: The transfer
failed. Server failed to authenticate the request. Make sure the value
of Authorization header is formed correctly including the signature.
HttpStatusMessage:Server failed to authenticate the request. Make sure
the value of Authorization header is formed correctly including the
signature. RequestId:76ffafce-901e-0132-6460-e00b82000000 Time:Fri, 22
Mar 2019 06:39:44 GMT [2019.03.22 06:39:44.161+03:00] Transfer
summary:
----------------- Total files transferred: 1 Transfer successfully: 0 Transfer skipped: 0 Transfer failed: 1 Elapsed time:
00.00:00:02
这是我尝试过的方法。
AzCopy /Source:D:\temp /Dest:https://account-name.blob.core.windows.net/blob-container-name /DestSAS:"?se=2019-03-30T18%3A30%3A00Z&sp=rw&sv=2018-03-28&sr=c&sig=xxxxx...%3D" /Pattern:test.txt
AzCopy /Source:D:\temp2 /Dest:"https://account-name.blob.core.windows.net/blob-container-name?se=2019-03-30T18%3A30%3A00Z&sp=rw&sv=2018-03-28&sr=c&sig=xxxxx...%3D" /Pattern:test.log
我注意到的一件事是,如果我只包含 Write
权限,操作就会失败。我必须在我的 SAS 中添加 Read
权限才能使操作成功。
此外,我必须在双引号中包含 SAS 令牌。
好的,我创建了一个 .CMD 文件用于 AzCopy 单个文件。但我不知道我必须在 windows 批处理文件中转义 % 。这就是为什么 SAS 令牌最后不正确的原因。
我有一个用于容器的 SAS(只写,但我也尝试读-写-列表)。我需要将单个文件上传到该容器。所以我为此使用 AzCopy:
AzCopy /Source:./ /Dest:https://account.blob.core.windows.net/container/?sv=2018-03-28&si=write&sr=c&sig=****** /Pattern:somefile.ext /V:./AzCopy.log
我尝试了另一个版本:
AzCopy /Source:somefile.ext /Dest:https://account.blob.core.windows.net/container/somefile.ext /DestSAS:******
但这也不管用。
而且我尝试了两个 AzCopy 版本 - 7.1.3 和 8.1!我还应该尝试什么?
顺便说一句,使用 Powershell 它就像一个魅力,具有相同的 SAS 令牌! Windows 10 个最新。
更新
日志(在完全不同的机器上制作):
[2019.03.22 06:39:41.551+03:00] >>>>>>>>>>>>>>>> [2019.03.22 06:39:41.561+03:00][VERBOSE] Finished: 0 file(s), 0 B; Average Speed:0 B/s. [2019.03.22 06:39:41.569+03:00][VERBOSE] 8.1.0 : AzCopy /Source:somefile.ext /Dest:https://account.blob.core.windows.net/korch/somefile.ext /DestSAS:****** /V:./AzCopy with SAS.log [2019.03.22 06:39:41.589+03:00][ERROR] An error occurred while reading the restart journal from "C:\Users\user\AppData\Local\Microsoft\Azure\AzCopy". Detailed error: Error parsing the journal file: Journal file was generated by a different version of AzCopy. [2019.03.22 06:39:43.175+03:00][VERBOSE] [PROMPT] Do you want to overwrite the journal to start a new operation? Choose Yes to overwrite, choose No to cancel current operation. (Yes/No) : Y [2019.03.22 06:39:43.230+03:00][VERBOSE] Attempt to parse address 'somefile.ext' to a directory as a candidate location succeeded. [2019.03.22 06:39:43.232+03:00][VERBOSE] Attempt to parse address 'somefile.ext' to a single file as a candidate location succeeded. [2019.03.22 06:39:43.239+03:00][VERBOSE] Source is interpreted as a Local file: G:\somefile.ext. [2019.03.22 06:39:43.260+03:00][VERBOSE] Attempt to parse address 'https://account.blob.core.windows.net/korch/somefile.ext' to a directory as a candidate location succeeded. [2019.03.22 06:39:43.269+03:00][VERBOSE] Attempt to parse address 'https://account.blob.core.windows.net/korch/somefile.ext' to a single file as a candidate location succeeded. [2019.03.22 06:39:43.270+03:00][VERBOSE] Interpreting destination as a single file as the provided source is a single file. [2019.03.22 06:39:43.271+03:00][VERBOSE] Destination is interpreted as a Cloud blob: https://account.blob.core.windows.net/korch/somefile.ext. [2019.03.22 06:39:43.942+03:00][VERBOSE] Start transfer: G:\somefile.ext => https://account.blob.core.windows.net/korch/somefile.ext [2019.03.22 06:39:44.149+03:00][VERBOSE] Transfer FAILED: G:\somefile.ext => https://account.blob.core.windows.net/korch/somefile.ext. [2019.03.22 06:39:44.158+03:00][ERROR] An unknown error occurred: The transfer failed. Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. HttpStatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:76ffafce-901e-0132-6460-e00b82000000 Time:Fri, 22 Mar 2019 06:39:44 GMT [2019.03.22 06:39:44.161+03:00] Transfer summary: ----------------- Total files transferred: 1 Transfer successfully: 0 Transfer skipped: 0 Transfer failed: 1 Elapsed time: 00.00:00:02
这是我尝试过的方法。
AzCopy /Source:D:\temp /Dest:https://account-name.blob.core.windows.net/blob-container-name /DestSAS:"?se=2019-03-30T18%3A30%3A00Z&sp=rw&sv=2018-03-28&sr=c&sig=xxxxx...%3D" /Pattern:test.txt
AzCopy /Source:D:\temp2 /Dest:"https://account-name.blob.core.windows.net/blob-container-name?se=2019-03-30T18%3A30%3A00Z&sp=rw&sv=2018-03-28&sr=c&sig=xxxxx...%3D" /Pattern:test.log
我注意到的一件事是,如果我只包含 Write
权限,操作就会失败。我必须在我的 SAS 中添加 Read
权限才能使操作成功。
此外,我必须在双引号中包含 SAS 令牌。
好的,我创建了一个 .CMD 文件用于 AzCopy 单个文件。但我不知道我必须在 windows 批处理文件中转义 % 。这就是为什么 SAS 令牌最后不正确的原因。