我是 Azure 的新手,我正在嘗試使用 cURL 來獲取我的 Azure blobe 中的專案串列。我已經配置了對 blob 的匿名讀取訪問

但是,當我運行此請求時:
curl -X GET -H "x-ms-version:2021-08-06" -H "x-ms-date:$(date -Ru | sed 's/\ 0000/GMT/')" https://name.blob.core.windows.net/name2
我得到:Server failed to authenticate the request. Please refer to the information in the www-authenticate header
我試圖添加"Authorization:Basic"或"Authorization:Anonumous"但不起作用。
我也嘗試過使用 SAS 令牌 URL 的其他方式

那么我的請求如下所示:
curl -X GET -H "x-ms-version:2021-08-06" -H "x-ms-date:$(date -Ru | sed 's/\ 0000/GMT/')" 'https://name.blob.core.windows.net/name2?sp=r&st=2022-10-12T19:53:09Z&se=2022-10-13T03:53:09Z&skoid=c49c35ef-99c7-49c5-835b-92418a2ccdb6&sktid=b1404f36-3c1b-42e2-9c8d-1b0066b5ff86&skt=2022-10-12T19:53:09Z&ske=2022-10-13T03:53:09Z&sks=b&skv=2021-06-08&spr=https&sv=2021-06-08&sr=c&sig=token'
但這會回饋:
<AuthenticationErrorDetail>Signature did not match. String to sign used was r
2022-10-12T19:53:09Z
2022-10-13T03:53:09Z
/blob/name/$root
c49c35ef-99c7-49c5-835b-92418a2ccdb6
b1404f36-3c1b-42e2-9c8d-1b0066b5ff86
2022-10-12T19:53:09Z
2022-10-13T03:53:09Z
b
2021-06-08
https
2021-06-08
c
</AuthenticationErrorDetail></Error>
我該如何解決這兩種情況?
uj5u.com熱心網友回復:
當您將訪問級別設定為“Blob”時,您需要使用 Blob 的完整 URL(例如https://account.blob.core.windows.net/container-name/blob-name)來訪問 Blob,而無需任何授權資訊。
但是,您為GET請求指定的 URL 是https://name.blob.core.windows.net/name2. 由于 Blob URL 不包含容器名稱,Azure 存盤嘗試在$root容器中查找 Blob。鑒于您已在名為alldatastorage(基于您的螢屏截圖)而不是$root容器上設定了權限,您將收到 403 錯誤。
要解決此問題,您需要做的就是使用 blob 的完整 URL。例如,如果您的 blob 名稱為myfile.txt,則您的 URL 將為https://name.blob.core.windows.net/alldatastorage/myfile.txt。在這種情況下,您不應該收到此錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/521099.html
