为blob存储容器生成SAS令牌(Powershell) [英] Generating a SAS token for a blob storage container (Powershell)

查看:267
本文介绍了为blob存储容器生成SAS令牌(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,并查看它是否有效。


https://docs.microsoft.com/ en-us / rest / api / storageservices / authentication-for-the-azure-storage-services


如果我使用Ym-d'T'H:M:S'Z'代替(%Y-%m-%dT%H:%M:strftime中的%SZ)它可以正常工作。


您也可以参考上面提到的建议这个
GitHub 链接




生成SAS令牌
使用PowerShell的Azure存储容器


az存储容器使用CLI生成sas


 


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.

https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services

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.

az storage container generate-sas using CLI


now=get-date


StorageContext = New-AzureStorageContext -StorageAccountName 'blo**rage18' -StorageAccountKey '8e6fNXZtVWE2FD2G***rVmVKpAR4i***ZM/860ppOEdvegwXP3KeiCR0Hgo/7ZoMTmZw=='


这篇关于为blob存储容器生成SAS令牌(Powershell)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆