我创建了一个 SAS 令牌,如果我使用 URL 访问私有容器,它似乎可以工作: https://mystorage.blob.core.windows.net/mycontainer?restype=container&comp=list&sv=2015-12-11&sr=c&sig =11111111111123%3D&se=2016-07-29T11%3A32%3A28Z&sp=cwl
代码:
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy()
{
Permissions = SharedAccessBlobPermissions.Create |
SharedAccessBlobPermissions.Write |
SharedAccessBlobPermissions.List |
SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(15)
};
var blobStorage = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobStorage.GetContainerReference(blobContainerName);
string sasContainerToken = container.GetSharedAccessSignature(policy);
但是,当我在 AzCopy(来自批处理文件)中使用此 sasContainerToken 时,我收到以下错误:
[2016-07-29 14:00:38][ERROR] The syntax of the command is incorrect.
Invalid SAS token in parameter "DestSAS". Value of "se" is invalid in SAS token.
问题似乎与时间有关,用“%3A”转义,将其更改为“:”可以解决错误,但现在由于 SAS 不正确,我没有被授权。
有任何想法吗?
更新:从 Azure 门户生成帐户 SAS 似乎解决了 AzCopy 错误,但仍然拒绝访问单个 blob 上传
AzCopy
/Source:C:\temp\myfiles
/Dest:"https://mystorage.blob.core.windows.net/mycontainer"
/DestSas:"?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-07-30T21:11:31Z&st=2016-07-28T13:11:31Z&spr=https&sig=p%2FlCgbgMRU7lH7111111YyxEDE21rZWFo4%3D"
将 /DestSas 更改为 /DestKey(使用有效密钥)有效,但提供了太多权限