I'm having trouble with a Laravel 6 app on Azure. I'm using TCG/Navigator to build my admin interface. Everything's hunky-dory in local development, but when I push the code to my development site in Azure, items from the storage disk are unavailable. I see this as broken images in the Navigator admin panel.
It looks like Laravel's file storage requires a symlink to operate:
https://laravel.com/docs/6.x/filesystem#the-public-disk
but symlinks don't appear to be supported in Azure's Windows web apps. I need something else to map /public/storage to /storage/app/public.
I can create a new virtual directory, but that didn't solve the problem. I mapped "/storage" to "site\wwwroot\storage\app\public" but I'm still seeing broken images in the Navigator admin panel.
I found this issue in Navigator's repo:
https://github.com/the-control-group/voyager/issues/417#issuecomment-304525223
and it seems like just the fix I need, but it's not working, either.
I've added:
'azure' => [
'driver' => 'local',
'root' => storage_path('..\public\storage'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
to filesystems.php. In voyager.php, I see:
'storage' => [
'disk' => env('FILESYSTEM_DRIVER', 'public'),
],
so to leave things as is (ie, working) in local dev, I've added an application setting to my web app:
FILESYSTEM_DRIVER, set to 'azure'
I know that my Azure web app is trying to use the azure filesystem because I initially forgot to push the updated code and my app told me it was missing.
So now I think my problem might be that I don't have the right values in the definition of the azure storage disk. Got any ideas? Or maybe suggestions on a different approach to try to get Laravel's file storage working on Azure?
I've solved this problem in what's probably the right way, but it isn't the solution I was looking for.
Ultimately, I need a place to store media that's uploaded through the site's admin interface. Navigator uses Laravel File Storage, which by default in local dev drops uploaded files into /storage/app/public. The quick and easy solution for deployment is if your dev/staging/prod servers work the same way; that is, uploaded files are stored in the /storage/app/public on the same server. This is what I was trying to do at first.
My development and production servers are on Azure, though. They are scalable web apps, so in theory, if my website is swamped with tons of users enjoying my content, multiple instances may be serving my content. I shouldn't expect every instance having the same local storage. The better scalable solution is for all uploaded content, regardless of which instance was running the admin interface that uploaded the content, to live in a dedicated file storage location. This might seem wacky at first, but it's the same concept as having one database spit out content for any number of webservers to display for users.
So after wrestling with the uncooperative symlink for 2 days, I jumped ahead to dedicated file storage location solution. And it worked! Here are the steps I took to make the magic happen:
'azure' => [
'driver' => 'azure',
'name' => env('AZURE_STORAGE_NAME'),
'key' => env('AZURE_STORAGE_KEY'),
'container' => env('AZURE_STORAGE_CONTAINER'),
'url' => env('AZURE_STORAGE_URL'),
'prefix' => null,
],
Whew. I'm still interested in learning if it's possible to get local storage working in an Azure web app, but this configuration leapfrogs me over that stumbling block toward a production-ready solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With