Unlocking Seamless Connectivity: Integrating WordPress with Microsoft Azure Storage

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

azure-wordpress.png

     The Microsoft Azure Storage for WordPress Plugin offers a seamless integration between your WordPress site and Azure Storage accounts.  While it effortlessly connects to Azure commercial storage accounts, connecting to storage accounts that are in different Azure environments, such as Azure Government, requires some modifications within the plugin's code.  By using this plugin, users can enhance their WordPress websites with the scalability and reliability of Azure Storage, ensuring efficient handling of media files and improving overall performance.

 

Installing the Microsoft Azure Storage for WordPress plugin and connecting to a commercial Azure Blob storage account

 

First, let's cover how to install and use the Microsoft Azure Storage for WordPress plugin.  To install the Microsoft Azure Storage for WordPress plugin, follow these step-by-step instructions:

  1. Access Your WordPress Dashboard: Log in to your WordPress website's admin area by navigating to your website's domain followed by "/wp-admin". For example, if your domain is "example.com", you would go to "example.com/wp-admin".

  2. Navigate to the Plugins Section: Once logged in, you'll find yourself in the WordPress dashboard. On the left-hand side, hover over the "Plugins" menu item, and then click on "Add New".

  3. Search for the Plugin: In the "Add Plugins" page, you'll see a search bar at the top right corner. Type "Microsoft Azure Storage" into the search bar and press Enter. The search results will populate below.

  4. Install the Plugin: Look for the "Microsoft Azure Storage" plugin in the search results. Once you find it, click the "Install Now" button next to the plugin name.
    jewalte_0-1709619743752.png

     

  5. Activate the Plugin: After the installation is complete, the "Install Now" button will change to "Activate".  Click on the "Activate" button to activate the plugin on your WordPress site.

  6. Configure the Plugin Settings: Once activated, you may need to configure the plugin settings to connect it to your Azure Storage account. Navigate to the plugin settings, usually found under the "Settings" menu in your WordPress dashboard.  

  7. Enter the required credentials and configuration settings to set up the connection between your WordPress site and Azure Storage.

         jewalte_2-1709619743771.png

      8. Verify Connectivity: After configuring the plugin settings, it's essential to verify that the connection to Azure Storage is established successfully.  You can do this by uploading a test file (such as an image or document) to your WordPress media library and confirming that it gets stored in your Azure Storage account instead of the local server.


HINT: A simple way to check if you are connected is to look at the Default Storage Container dropdown. If it shows your containers or a "Create New Container" option, you are connected. Make sure you enter the correct credentials and click save at the bottom of the page first.

 

That's it! You've now successfully installed and configured the Microsoft Azure Storage for WordPress plugin, enabling your WordPress site to utilize Azure Storage for storing media files and other assets.

 

Modifying the Microsoft Azure Storage for WordPress plugin code to establish connectivity to non-commercial storage accounts.

 

  In certain scenarios, customers may find the need to connect to Azure storage accounts in environments other than the standard Azure commercial setting. These scenarios often arise due to regulatory requirements or specific data residency needs. Here are some examples:

- Azure Government Services: In the Azure Government cloud, the endpoint URLs for Azure Blob Storage differ from the standard .blob.core.windows.net. The endpoint might have a suffix like .blob.core.usgovcloudapi.net to distinguish government services from regular Azure services.


- Azure China 21Vianet: Azure services operated by 21Vianet in China have unique endpoint URLs. For instance, the Blob Storage endpoint in Azure China typically ends in .blob.core.chinacloudapi.cn.


- Azure Germany: Historically, Azure Germany had distinct endpoint suffixes, such as .blob.core.cloudapi.de, catering to German customers' requirements based on local data handling laws and regulations.

 

When encountering these scenarios, modifying the Azure Storage WordPress plugin becomes necessary to establish connectivity.

To link a WordPress site on Azure with Azure Blob Storage in a non-commercial environment, the following changes are required within the code of the plugin.  

 

  1.  From within your Wordpress admin dashboard, select Tools from the side bar then select Plugin File Editor.  Select the Azure Storage for Wordpress Plugin from the select plugin to edit, dropdown menu.  Open the class-windows-azure-rest-api-client.php file within the Microsoft Azure Storage for WordPress plugin directory.  Follow the steps shown in the screen recording below to find the class-windows-azure-rest-api-client.php file.

    AzureStorageWordpressGif.gif

     


     

  2. Locate line 88 in the file, where the constant API_BLOB_ENDPOINT is defined.

  3. Update the value of API_BLOB_ENDPOINT from 'blob.core.windows.net' to the endpoint suffix corresponding to the desired Azure environment. For example, change it to 'blob.core.usgovcloudapi.net' for Azure Government.

Screenshot 2024-03-06 125926.png

 

  1. Scroll down to line 554 in the same file, where the connection string for Azure Blob Storage is constructed.

  2. Modify the connection string to include the EndpointSuffix parameter with the appropriate value for the targeted Azure environment. Append ';EndpointSuffix=core.usgovcloudapi.net' to the existing connection string for Azure Government compatibility.

jewalte_4-1709619743793.png

 

  1. Save the changes to the class-windows-azure-rest-api-client.php file.
  2. After saving the modifications, ensure that the WordPress site is reloaded or the plugin is refreshed to apply the changes.

  3. Test the connection by uploading a file to the WordPress media library and verifying that it gets stored in the Azure Blob Storage account associated with the specified Azure environment.

By implementing these changes, WordPress sites can effectively connect to Azure Blob Storage using the Microsoft Azure Storage for WordPress Plugin. Moreover, the plugin can be adapted to connect to Blob Storage accounts in various Azure environments, including Azure China Cloud, Azure German Cloud, and Azure US Government, by adjusting the blob endpoint suffix accordingly.

For further guidance on utilizing Azure Storage across different environments, users can refer to the official Microsoft documentation available at https://learn.microsoft.com/en-us/azure/storage/common/storage-powershell-independent-clouds#endpoint-suffix. This resource provides valuable insights into configuring Azure Storage solutions tailored to specific requirements and environments.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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