为blob存储容器生成SAS令牌(Powershell) [英] Generating a SAS token for a blob storage container (Powershell)
问题描述
在查看文档后,它看起来非常直接,我得到了这一点:
az存储容器generate-sas --name" container_name" --connection-string" storage_account_connection_string" --https-only --permissions" w" --expiry" 2019-6-20T00:00Z"
$
此行导致我获得SAS令牌,但当我查看门户时我无法确认确实创建了一个。
当我尝试使用azcopy确实通过使用时确认这一点:
$
azcopy copy" file_path" " https://storage_account_name.blob.core.windows.net/container_name?SAS"
我确实得到:
身份验证失败,它不正确,或过期,或没有正确的权限。
AuthenticationErrorDetail:se是必需的。不能为空
代码:AuthenticationFailed
RESPONSE状态:403服务器无法验证请求。确保授权标题的值正确形成,包括签名。
我想我错过了基本的东西,但我无法弄清楚是什么。
403表示您的SAS令牌或共享有问题键。您可以使用存储资源管理器生成具有相同配置的SAS,并查看它是否有效。
如果我使用Ym-d'T'H:M:S'Z'代替(%Y-%m-%dT%H:%M:strftime中的%SZ)它可以正常工作。
您也可以参考上面提到的建议这个
GitHub 链接
为
生成SAS令牌
使用PowerShell的Azure存储容器。
now = get-date
StorageContext = New-AzureStorageContext -StorageAccountName'blo ** rage18'-StorageAccountKey'8e6fNXZtVWE2FD2G *** *** rVmVKpAR4i ZM / 860ppOEdvegwXP3KeiCR0Hgo / 7ZoMTmZw =='
After looking at the docs it seemed very stright forward, and I got to the point I have this line:
az storage container generate-sas --name "container_name" --connection-string "storage_account_connection_string" --https-only --permissions "w" --expiry "2019-6-20T00:00Z"
This line result in me getting a SAS token, but when i look in the portal I can not confirm one was indeed created.
When I try to use azcopy to indeed confirm this by using:
azcopy copy "file_path" "https://storage_account_name.blob.core.windows.net/container_name?SAS"
I indeed get:
Authentication failed, it is either not correct, or expired, or does not have the correct permission.
AuthenticationErrorDetail: se is mandatory. Cannot be empty
Code: AuthenticationFailed
RESPONSE Status: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
I guess I'm missing somthing basic but I can not figure out what.
403 means there is something wrong with your SAS token or shared key. You can use storage explorer to generate SAS with the same configuration and see if it works.
If I use Y-m-d'T'H:M:S'Z' instead (%Y-%m-%dT%H:%M:%SZ in strftime) it works correctly.
You may also refer to the suggestion mentioned in this GitHub link
Generates an SAS token for an Azure storage container using PowerShell.
now=get-date
StorageContext = New-AzureStorageContext -StorageAccountName 'blo**rage18' -StorageAccountKey '8e6fNXZtVWE2FD2G***rVmVKpAR4i***ZM/860ppOEdvegwXP3KeiCR0Hgo/7ZoMTmZw=='
这篇关于为blob存储容器生成SAS令牌(Powershell)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!