AuthenticationFailed после создания токена SAS с помощью New-AzStorageBlobSASToken - PullRequest
0 голосов
/ 14 января 2020

Я создаю токен SAS:

$start = [System.DateTime]::Now.AddMonths(-1)
$end = [System.DateTime]::Now.AddMonths(1)
$cloudConfigSas = New-AzStorageBlobSASToken -Container "myContainer" -Blob "myBlob" -Permission "rwd" -Protocol HttpsOnly -StartTime $start -ExpiryTime $end -FullUri -Context $storageContext

Полный URI имеет этот формат:

https: // {myStorage} .blob.core. windows .net / {MyContainer} / {myBlob}. json? SV = 2019-02-02 & ср = Ь & сиг = M8ZphKYAVr8vUk5V2F5QkcJOCmp05% 2ByoPhcWPMrcSeI% 3D & SPR = HTTPS & й = 2020-01-12T22% 3A54% 3A14Z & SE = 2021-01-13T22% 3A54% 3A14Z & зр = rwd

При попытке доступа к нему я получаю следующую ошибку

<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:{myRequestID} Time:2020-01-14T00:19:08.2434298Z</Message>
<AuthenticationErrorDetail>Signature did not match. String to sign used was rwd 2020-01-12T22:54:14Z 2021-01-13T22:54:14Z /blob/{myStorage}/{myContainer}/{myBlob} https 2019-02-02 b </AuthenticationErrorDetail>
</Error>

1 Ответ

1 голос
/ 14 января 2020

В моем тесте ваш скрипт должен работать. Попробуйте использовать New-AzStorageContext, как показано ниже.

$storageContext = New-AzStorageContext -StorageAccountName storageaccount -StorageAccountKey 4i41SDZ3xxxxxxZJYA==
$start = [System.DateTime]::Now.AddMonths(-1)
$end = [System.DateTime]::Now.AddMonths(1)
$cloudConfigSas = New-AzStorageBlobSASToken -Container "test1" -Blob "batch.json" -Permission "rwd" -Protocol HttpsOnly -StartTime $start -ExpiryTime $end -FullUri -Context $storageContext

enter image description here

enter image description here

Доступ это в браузере:

enter image description here

...