PowerShell 中的 Azure CLI 和 SAS 令牌问题

发布于 2025-01-09 01:25:21 字数 556 浏览 3 评论 0原文

我在 Azure 门户中生成了 SAS 令牌,并尝试使用它将文件上传到 blob 存储:

az 存储 blob upload-batch --source ./test --destination '$web' --account-name 'myaccountname' --sas-token '"sp=racwl&st=2022-02-22T17:04:19Z&se=2022-12-23T01:04:19Z&spr=https&sv=2020-08-04&sr=c&sig=mXXXXXXXXXXXXXXXXXXXXXXXXXXXONfAA% 3D”'

但上面的命令给了我以下错误在 PowerShell 中:

<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>

我实际上是从 Azure 门户复制 SAS 令牌,那么它到底怎么会出现格式错误呢?

I generated SAS token in Azure Portal and trying to use it to upload files to blob storage:

az storage blob upload-batch --source ./test --destination '$web' --account-name 'myaccountname' --sas-token '"sp=racwl&st=2022-02-22T17:04:19Z&se=2022-12-23T01:04:19Z&spr=https&sv=2020-08-04&sr=c&sig=mXXXXXXXXXXXXXXXXXXXXXXXXXXONfAA%3D"'

But above command gives me following error in PowerShell:

<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>

I am literally copying the SAS Token from Azure Portal so how on earth can it be malformed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

友欢 2025-01-16 01:25:21

我们在本地环境(使用 powershell v5.1 运行)中运行了相同的 az storage blob upload-batch cmdlet我们可以将文件从本地计算机上传到存储帐户,如下所示。

这是我们使用的 cmdlet:

az storage blob upload-batch --account-name <strgAccountName> -s <sourcefilepath> -d 'https://xxxxxx.blob.core.windows.net/cont1' --sas-token '<generatedSAStoken from portal>'

这是供参考的示例输出:

在此处输入图像描述

注意:

cmdlet,我们已经尝试过传递 SAS 令牌并附加(单引号+问号)“?” &在这两种情况下,无需将单引号传递给 --sas-token 标志,我们就可以将文件从本地计算机上传到 Azure 存储容器。

We have ran the same az storage blob upload-batch cmdlet in our local environment( which is running with powershell v5.1) & we are able to upload the files from local machine to the storage account as shown in below.

Here is the cmdlet we have used :

az storage blob upload-batch --account-name <strgAccountName> -s <sourcefilepath> -d 'https://xxxxxx.blob.core.windows.net/cont1' --sas-token '<generatedSAStoken from portal>'

Here is the sample Output for reference:

enter image description here

Note:

To the above cmdlet, We have tried passing the SAS token with appending(single quote+ question mark) '?' & without passing in single quote's to the --sas-token flag in both the cases we are able to upload the files from local machine to Azure storage container.

青瓷清茶倾城歌 2025-01-16 01:25:21

我不知道出了什么问题,但突然它开始以 '"sastoken"' 格式工作。感谢您的回复。

I don't know what was wrong, but suddenly it started to work with '"sastoken"' format. Thanks for your responses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文