Making W3-Total-Cache work with Storage Accounts in Azure Government


So you thought you were going to be slick and save some time by using the Marketplace template to deploy “WordPress on App Service” in Azure Government? You likely even selected the ‘Recommended’ tick-box to offload media content to Azure Blob Storage via the template add-on section and then hit “Review and Create!” But when you logged finally in and created your first post with some media, you noticed an error message that content couldn’t be uploaded to Azure Blob Storage using W3-Total-Cache plugin for WordPress… You poked your way through the WordPress configuration to the Plugin Settings and found this section:

Yours DOES NOT look like mine above. 😉 (I forgot to get a BEFORE screenshot. Woops) Despite “or CNAME” box having the correct “usgovcloudapi.net” base DNS name in that box, when you click Test Microsoft Azure Storage upload – you receive something to the effect of: Unable to resolve DNS name <storageaccountname>.blob.core.windows.net.

The problem? The w3-Total-Cache plugin is using the deprecated Azure Storage PHP Client Libraries that appear to have a hard-coded service URL that only works in Azure Commercial. If you modify line 54 of the Resources.php file from blob.core.windows.net to blob.core.usgovcloudapi.net, you’ll have a lot easier time! You’re welcome! 🙂