Azure WordPress on App Service and the WordPress Query Monitor Plugin

If you are running your WordPress website on Azure App Services (specifically on the WordPress for App Services service) like DCAC is and you are using the Query Monitor WordPress plugin, there’s a setting that you’ll want to be aware of before you enable Database Extended Query Information (granted this is most helpful for plugin development).

Before turning on the Database Extended Query Information (which requires that you use Web SSH to connect to the host and run one of the commands listed or the Query Monitor website), there’s a setting in Azure that you’ll want to turn off. The Azure team has enabled some additional caching at the application level, which increases the responsiveness of the WordPress websites hosted within the App Service. However, something in this caching causes the Database Extended Query Information feature of the Query Monitor plugin to go through an error message. My guess is that because this is causing a symlink to be created on the backend, there is some weirdness with the caching. (If you aren’t familiar with a symlink in Linux, that’s fine; it’s basically a pointer to another file.)

To prevent this error, disable this caching in the app service. The Azure team has made this very easy. Navigate to the Azure portal and sign in as normal. Search for App Services and select “App Services” from the list below.

Once the list of app services appears, select the one that you want to edit. When that opens, select “Environment variables” from the menu (you can either search for it or you’ll find it under the “Settings” group.

Once you’ve clicked on “Environment variables,” find the setting named “WORDPRESS_LOCAL_STORAGE_CACHE_ENABLED” and click on the name. This will open the editor. If you value is set to “true”, change the value to “false” and click “Apply” at the bottom. After the blade closes, you’ll need to click “Apply” at the bottom of the Environment Variables list as well. This will pop up a confirmation that your App Service will need to be restarted, so click OK on this.

Before I learned of this setting, I had enabled the feature. The symptom I saw was that my App Service was running fine for about 5 minutes, then it would show a WordPress error message saying there was a critical error on my site. When I turned on the debugging features on WordPress (editing the website’s config file via WebSSH), it returned this error message.

Fatal error: Cannot declare class ComposerAutoloaderInitad25d53a23099da4b0886b4f6754360e, because the name is already in use in /var/www/wordpress/wp-content/plugins/query-monitor/vendor/composer/autoload_real.php on line 5

From working with the WordPress on App Services team, I know that the website isn’t hosted in /var/www/wordpress, but instead in /home/site/wwwroot so clearly something weird was going on. Needless to say, this change will fix the error that you are seeing.

Denny

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trust DCAC with your data

Your data systems may be treading water today, but are they prepared for the next phase of your business growth?