Taking advantage of Windows Azure Storage from PHP: example with a WordPress plugin

Continuing our efforts on improving interoperability between PHP and Microsoft technologies, we have created an example showcasing a new plugin for WordPress that allows WordPress developers to take advantage of the storage capacity of Windows Azure. This plugin enables WordPress to use Windows Azure Storage Service to host media for a WordPress-powered blog.

The plugin, developed by Microsoft, is now available as an open source project from the WordPress repository: http://wordpress.org/extend/plugins/windows-azure-storage/

About Windows Azure Storage and Content Delivery Network (CDN)

Windows Azure Storage enables applications to store and manipulate large objects and files in the cloud via blobs, manipulate service state via tables, and provide reliable delivery of messages using queues. You can read more about Windows Azure Storage here.

If you want to manage your media (images or any file offered for download) in a consistent way and share them across multiple websites then you might want to consider using Windows Azure Storage blobs. Windows Azure includes a service called Windows Azure Content Delivery Network (CDN) which offers developers a solution for delivering high-bandwidth content. Windows Azure CDN has currently 18 locations globally (United States, Europe, Asia, Australia and South America). Windows Azure CDN caches your Windows Azure blobs at strategically placed locations to provide maximum bandwidth for delivering your content to users. The benefit of using a CDN is better performance and experience for users who are farther from the source of the content stored in the Windows Azure Storage blobs. You can read more on the Windows Azure Team Blog and on MSDN

Windows Azure Storage from PHP with a WordPress plug-in.

The Windows Azure Storage plugin for WordPress allows developers running their own instance of WordPress to take advantage of the Windows Azure Storage services, including the Content Delivery Network (CDN) feature. It provides a consistent storage mechanism for WordPress Media in a scale-out architecture where the individual web servers don’t share a disk. Note that this scenario goes beyond WordPress and could also be very compelling any other web application where there’s a need to load balance across a number of web servers without shared disk.

The plugin is a regular WordPress plugin developed in PHP, and can be deployed on any WordPress instance (running on Windows or Linux - requires at least version 2.8.0 and tested up to version 2.8.4). The plugin uses the Windows Azure SDK for PHP to handle the interactions with Windows Azure.

Once the plugin is installed you’ll see it in the WordPress plugins management interface.

Once the plugin is activated and configured, which simply consists of setting your Windows Azure account information and a few options, you can use it directly through the blog post editor:

To include an image in the post, just click on the “Azure” icon. The following screen will pop up:

From here you simply pick the image you want to include.

When the plugin is installed, you can choose to have all media managed through the WordPress Media Management interface or during imports to also go to Windows Azure blob storage. Then it shows up in the regular list of media elements and not just under the Azure button.

Once you have published the post you can see that your image lives on Windows Azure Storage, although your WordPress applications can be hosted anywhere else.

Give it a try!

The plugin is now available from the WordPress repository: http://plugins.svn.wordpress.org/windows-azure-storage/. Register for your Windows Azure account (try for free till July 31, 2010 with the Introductory Special), install the plugin, and get started!

Feel free to share feedback!

Additional links

-- Jean-Christophe Cimetiere, Sr. Technical Evangelist, @openatmicrosoft

Comments (3)
  1. Kevin Lisota says:

    My ISP won't install the Azure SDK in their hosted WordPress environment. Is there an alternative to make this work? I'd like to use the Azure CDN.

  2. JC Cimetiere says:

    @Kevin Lisota:

    The plugin has a dependency on the Windows Azure SDK for PHP which need to be extracted from the zip file and placed on the server where WordPress is installed, e.g. in "/usr/local/PHPAzureSDK/" folder. See this link for more details: wordpress.org/…/installation

    If you cannot modify the PHP.ini: PHP application can dynamically modify include_path by using following code before calling any function from Windows Azure PHP SDK.

    set_include_path(get_include_path() . PATH_SEPARATOR .  ‘<ADD_PATH_TO_MICROSOFT_FOLDER_FROM_WINDOWS_AZURE_PHP_SDK>’);

    This has to be done in windows-azure-storage.php file of the plugin as this file uses SDK classes. And if the hoster does not provide file system access to WordPress plugin code, this cannot be done.  

    Then only way to achieve is to distribute Windows Azure SDK for PHP (phpazure.codeplex.com/…/36423) along with plugin and add set_include_path in the windows-azure-storage.php file that refers to SDK code in plugin directory.

    Hope this helps!

  3. Kevin Lisota says:

    Thanks @jccim

    Setting the path worked, but now I have a new problem.

    I'm getting these errors when uploading to the Azure storage account. The files do upload, but the uploaders error with the following:

    CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set (this is for line 85 of curl.php)

    The server is a shared hoster with PHP 5.2.12 and it appears that it is running in safe mode. Any thoughts on getting around this?

Comments are closed.

Skip to main content