Use Azure File Share as Uploads Directory for WordPress in Docker

Matthew Woodward 1 Reputation point
2021-09-14T21:45:11.467+00:00

Hi there -- I'm semi-new to Azure and am trying to figure out the best way to run a WordPress site, but use an Azure File Share as the uploads directory.

Thus far I've pushed my WordPress image up to the Azure Container Registry and have it running in an App Service, and at a basic level that's working great.

I then went into the app service configuration and added a path mapping pointing to the Azure File Share, and set the mount point as /var/www/html/wp-content/media. I also added define( 'UPLOADS', 'wp-content/media' ); to the WORDPRESS_CONFIG_EXTRA application setting, and also added WEBSITES_ENABLE_APP_SERVICE_STORAGE with a value of TRUE as an application setting.

When I upload a test image the upload works, and the file shows up in the file share, but the image doesn't appear in the media library in the admin (there's a box but it's empty), and when I try to browse to the URL for the image directly I get a 502 error.

I'm assuming it has something to do with perhaps needing a location defined at the web server level, but if I'm using the stock Docker WordPress image, I wasn't sure how best to go about doing that and my Google fu is failing me.

As a broader question, is the approach I'm taking of using a path mapping to the Azure File Share even the best way to do this? Am I better off setting up the File Share as a CDN and using a CDN plugin instead? Writing directly to the filesystem seemed to be the more direct route, but I'd love to learn from the experience of others who've done this.

Thanks!

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,170 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
645 questions
{count} votes