我正在做一个 Laravel 9 项目,我将图像存储在 azure 帐户上。 我使用这个库https://github.com/matthewbdaly/laravel-azure-storage .
我尝试连接 SAS token ,它可以工作,但当我尝试读取它时,我得到了 AuthorizationPermissionMismatch :
Route::get('/azure-test', function() {
$path = '';
$disk = \Storage::disk('azure');
$files = $disk->files($path);
dump($files);exit;
}
我的配置:
'driver' => 'azure',
'driver' => 'azure',
'sasToken' => env('AZURE_STORAGE_SAS_TOKEN'),
'container' => env('AZURE_STORAGE_CONTAINER'),
'url' => env('AZURE_STORAGE_URL'),
'prefix' => null,
'endpoint' => env('AZURE_STORAGE_ENDPOINT'),
'retry' => [
'tries' => 3,
'interval' => 500,
'increase' => 'exponential'
],
为了明确文件存在,我在没有 SAS token 配置的情况下测试它,它显示有关我的测试文件的信息。我已经搜索并做了一些更改,例如将我的帐户分配给角色“存储 Blob 数据贡献者”和“存储队列数据贡献者”,当我尝试查看我的文件“https://xxxxxxxx.blob.core”时,我的 sas token 仍然有效.windows.net/container_name/im_test_file.pdf?sp=r&st=2022-06-24T15:32:22Z&se=2024-04-30T23:32:22Z&sv=2021-06-08&sr=c&sig=QSz6SZ6UrSMg0jqyKEr4bnnGqrMuxK2EI bGgTTbP%2F10%3D"它有效。
有什么想法吗?
最佳答案
AFAIK,要解决“AuthorizationPermissionMismatch”错误,请尝试分配 Storage Blob Data Reader您的帐户的角色如下:
Please note that Azure role assignments can take up to five minutes to propagate.
检查您在创建 SAS token 时是否已授予以下权限:
欲了解更多详情,请引用以下链接:
Authorize access to blobs with AzCopy & Azure Active Directory | Microsoft Docs
Fixed – authorizationpermissionmismatch Azure Blob Storage – Nishant Rana's Weblog
关于php - Laravel 9 Azure 存储 Blob 服务器授权权限不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72746453/