亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

嘗試在 Laravel 中使用 Azure 存儲模擬器

嘗試在 Laravel 中使用 Azure 存儲模擬器

PHP
藍山帝景 2022-07-16 10:54:15
我正在嘗試在 Laravel 5.8 中實現 Azure 存儲模擬器它適用于 Azure 開發和生產,但不適用于本地 Windows。郵遞員返回"message": "Fail:\nCode: 403\nValue: Server failed to authenticate the request.確保 Authorization header 的值包括簽名在內的格式正確。\ndetails (if any): .",    "異常": "MicrosoftAzure\\Storage\\Common\\Exceptions\\ServiceException",    "file": "C:\\Code\\web-portal-laravel\\vendor\\microsoft\\azure-storage-common\\src\\Common\\Internal\\ServiceRestProxy.php",像公共和私人文件夾一樣,我們正在嘗試將其實現為存儲磁盤。我們認為只使用相同類型的條目 - 而是使用 .env 文件中的共享密鑰憑據會起作用:    AZURE_STORAGE_URL_EMU = "http://127.0.0.1:10000/devstoreaccount1/local"    AZURE_STORAGE_KEY_EMU =        "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVERCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="    AZURE_STORAGE_ACCOUNT_EMU = "devstoreaccount1"    AZURE_STORAGE_CONTAINER_EMU = "本地"存儲資源管理器已安裝并可以看到 Blob、隊列和表。模擬器的狀態報告:    Windows Azure Storage Emulator 5.10.0.0 命令行工具    正在運行:真    BlobEndpoint:http://127.0.0.1:10000/    隊列端點:http://127.0.0.1:10001/    表端點:http://127.0.0.1:10002/我不知道什么樣的 Authorization 標頭可以使它起作用。我們正在使用 matthewbdaly/laravel-azure-storage 插件。
查看完整描述

1 回答

?
慕標琳琳

TA貢獻1830條經驗 獲得超9個贊

根據Connect to the emulator account using the well-known account name and key官方文檔的部分Use the Azure storage emulator for development and testing,Azure Storage Emulator 的連接字符串應該如下所示。


DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;

AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;

BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;

TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;

QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;

src/AzureStorageServiceProvider.php看了下plugin的源碼matthewbdaly/laravel-azure-storage,發現下圖的代碼只支持云上Azure Storage的連接字符串,不支持Emulator。

http://img1.sycdn.imooc.com//62d229370001550509540851.jpg

因此,如果不更改插件的任何代碼,將config/filesystems.php文件配置為插件 repo 的內容的解決方法README如下。


'azure' => [

        'driver'    => 'azure',

        'name'      => 'devstoreaccount1',

        'key'       => 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;',

        'container' => env('AZURE_STORAGE_CONTAINER'),

        'url'       => env('AZURE_STORAGE_URL'),

        'prefix'    => null,

],

然后,模擬器連接字符串可以正確地由key上面的值與字符串模板代碼補充'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s'。


查看完整回答
反對 回復 2022-07-16
  • 1 回答
  • 0 關注
  • 141 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號