php - Laravel 9 Azure 存储 Blob 服务器授权权限不匹配

标签 php laravel azure azure-blob-storage sas-token

我正在做一个 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您的帐户的角色如下:

enter image description here

Please note that Azure role assignments can take up to five minutes to propagate.

检查您在创建 SAS token 时是否已授予以下权限:

enter image description here

欲了解更多详情,请引用以下链接:

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/

相关文章:

azure - PnP.Framework.AuthenticationManager 与 ConfidentialClientApplicationBuilder

php - 通过 PHP 使用 Google 身份验证 API

php - 注销时 Symfony 2 不会删除记住我的 cookie

php - 将 MYSQL 字符串插入图像源以进行显示

php - Laravel - 过去 7 天的查询计数值

azure - 将第二个区域添加到现有 API 管理时是否会出现中断?

php - 如何使用 fpdf 生成包含 Bangla (Unicode) 字体的 PDF?

javascript - jQuery Post 返回页面源代码 (laravel)

php - 过滤集合时删除键 laravel

Active Directory 应用程序 MainLogo 图片上传期间 Powershell 错误