【发布时间】:2025-12-22 00:50:16
【问题描述】:
任何人都可以帮助解决使用 SAS 密钥执行 azCopy 时出现的错误吗?
我通过 SSH 连接到我的 Azure VM 并使用它的托管标识获取令牌:
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com' -H 元数据:真的
然后,我构建了一个邮递员请求,其“授权”标头为“Bearer tokenFromAbove”,JSON 正文为:
{
"signedServices":"b",
"signedResourceTypes":"co",
"signedPermission":"rwc",
"signedProtocol":"https",
"signedExpiry":"2020-02-22T00:06:00Z"
}
并返回一个 sas 令牌。这个令牌允许我使用“azcopy make”创建一个容器。
但我还想使用“azcopy copy”将文件从我的 VM 移动到新容器。我通过以下命令尝试:
azcopy copy 'mySourceDirectory' 'https://myStorageAccountName.blob.core.windows.net/myContainer?sv=2015-04-05&ss=b&srt=co&sp=rwc&se=2020-02-22T00:06:00Z&spr=https&sig=redacted' --recursive
但这失败了:
INFO: Authentication failed, it is either not correct, or expired, or does not have the correct permission -> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, /home/vsts/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.7.0/azblob/zc_storage_error.go:42
===== RESPONSE ERROR (ServiceCode=AuthenticationFailed) =====
Description=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:ef37087d-501e-0050-650b-e81cb4000000
Time:2020-02-20T16:35:50.6651356Z, Details:
AuthenticationErrorDetail: **Signature did not match**.
String to sign used was myStorageAccountName
rwc
b
co
2020-02-22T00:06:00Z
https
2015-04-05
Code: AuthenticationFailed
请注意,如果我在 Azure 门户中生成类似的 SAS 令牌,它可以工作。我的 VM 是存储帐户的所有者。
【问题讨论】:
-
您能分享一下您是如何使用 azcopy 的吗?
-
更新了帖子,谢谢。
-
您可以尝试将
list(l) 权限添加到SAS 吗?所以你的权限是rwcl。 -
很遗憾,没有变化。我已经尝试了 SignedServices、SignedResourceType 和 SignedPermission 的所有选项。
-
这是 azcopy 中的一个错误:github.com/Azure/azure-storage-azcopy/issues/122
标签: azure authentication token azcopy