I love the name of this newly announced tool, currently available as a Customer Technology Preview… but I just can’t get Garrison Keillor out of my mind!
The Windows Azure Companion is one of several tools and updates (announced at OSI Days 2010) that are focused on PHP developers looking to leverage the Windows Azure cloud computing platform. In addition to the “Companion”, which is the main topic of this post, there are updates for three other offerings of interest to the PHP audience:
- The update for Windows Azure Command-line Tools for PHP includes support for running the Hosted Web Core on a Worker Role. That may seem a tad redundant given that a Web Role already contains a hosted web core and supports PHP via FastCGI, but what this now allows you to do is share cycles of a potentially underutilized worker role between serving up the PHP site and performing background processing (read: save you money on compute costs in Azure!)
- Lastly, there’s an update for the Windows Azure SDK for PHP, now at Version 2.0. The SDK enables PHP developers to leverage Azure storage services (blobs, tables and queues) and the content delivery network (CDN), regardless of where they are hosting the PHP application.
What is the Windows Azure Companion?
The Windows Azure Companion is a ready-made administrative web site that you run on your account in Azure. The site allows you to install frameworks, like PHP, and other 3rd party applications, like WordPress, Drupal and Joomla!, directly into the same Azure service instance hosting the Companion (a worker role, by the way) If this kind of thing sounds familiar, well it is; think of the Windows Azure Companion as the cloud analogy of the Web Platform Installer.
You may be aware that you can already host PHP, MySQL, Java, and a host of other non-Microsoft frameworks and applications on Windows Azure, and there are a number of solution accelerators (PHP/MySQL, Tomcat, memcached, etc.) available to help you out. The Windows Azure Companion takes things to the next level, providing a single point of administration for hosting and managing frameworks and applications in Azure. Right now it’s focused on PHP-based applications, given the popularity of CMSes like WordPress and Drupal, but it certainly seems like a platform that could be easily extended in the future.
Getting Started with the Windows Azure Companion
To put this new tool through its paces, I thought I’d try installing WordPress on Azure, so the rest of this post will walk through doing just that, and in doing so we should touch upon most of the features.
Window Azure Companion is hosted on the MSDN Code Gallery, and when you visit the project site, you’ll see the five download options shown below. The first four are variants of an Azure cloud service which you can quickly upload within a provisioned Azure account (don’t have an Azure account? check out AzurePassUSA!). Those options differ only by the VM size of the worker role to which you’re deploying – the same worker role that will host whatever applications you install via the Windows Azure Companion. The code is available, so the last option can be used to tailor the utility to your own needs or just to satisfy your own curiosity as to how it all works under the covers.
We’ll start simple, with the small VM prepackaged option (WindowsAzureCompanion-SmallVM-Sep2010CTP.zip). When you download that ZIP file, you’ll get two files in the archive (ok, there’s three, but does anyone actually read the license.txt?). If you’ve done deployments on Windows Azure before, you’ll recognize the files as a .cspkg, which contains your compiled application code, and a .cscfg file, which contains the service configuration XML document (kind of like a web.config for you ASP.NET developers, but applying to the entire cloud service).
Before you deploy the service to Windows Azure, a few modifications to the service configuration file are required:
- Specify your Azure storage account (Lines 2 and 3, below),
- Set up an admin account for accessing the Windows Azure Companion once it’s running (Lines 6 through 8), and
- Specify a feed (Line 11) that indicates what applications are available to be installed. For this example, I’ve piggybacked off of a feed that Maarten Balliauw has made available, but you can generate your own following the Windows Azure Companion Feed Schema.
1: <!-- Windows Azure Storage Account Details. -->
2: <Setting name="WindowsAzureStorageAccountName" value="wacstorage" />
3: <Setting name="WindowsAzureStorageAccountKey" value="redacted" />
5: <!-- Admin user name, password and e-mail. Please user strong username and password -->
6: <Setting name="AdminUserName" value="admin" />
7: <Setting name="AdminPassword" value="redacted" />
8: <Setting name="AdminEmail" value="email@example.com" />
10: <!-- Atom Feed for Product items to be installed. This URL should be internet addressable -->
11: <Setting name="ProductListXmlFeed" value="http://wazstorage.blob.core.windows.net/azurecompanion/default/WindowsAzureCompanionFeed.xml" />
Next, deploy your application to a new hosted service on your Azure account. If you need a refresher for this part, refer to the “To select a project and create a compute service” section of this walkthrough on MSDN, using the .cspkg and (just updated) .cscfg files comprising the Windows Azure Companion application. Once it’s deployed you can browse to it at port 8080 (don’t forget that part!) of whatever URL you specified when you set up the Azure hosted service (compute) instance.
You’ll be greeted with a welcome message via an ASP.NET MVC application; that message, by the way, is configurable via the ApplicationDescription setting in the ServiceConfiguration.cscfg. Upon logging in (via the link in the upper right), you’ll have access to the other functionality of the Windows Azure Companion as well.
Installing PHP and WordPress
The Platform tab exposes elements of the ProductListXmlFeed with a matching
<tabname> tag. My feed includes PHP and the PHP Wincache Extension, both of which seem like a good way to my goal of installing WordPress.
But, wait a minute… WordPress requires PHP to run, and since the Windows Azure Companion is aware of those prerequisites (well, so long as they are included in the ProductListXmlFeed as dependencies), why not just go straight there?
So on to the Applications tab, which here includes WordPress along with some other popular Open Source PHP packages.
I’m picking only WordPress in this case, and so the next screen prompts for some versioning information for WordPress along with similar requests for other prerequisites. Note here that the PHP drivers for SQL Server will be installed, so this implementation of WordPress will use SQL Server versus MySQL, although MySQL can also be run on Windows Azure.
While the applications are installing, you’ll see progress messages appear on the Admin tab of the Windows Azure Companion site. Those messages, by the way, are recorded to the Windows Azure Storage account you configured in the .cscfg file.
Upon completion, the application will show as installed and ready to Launch.
At this point, WordPress is installed, but it’s not yet configured. If you’ve installed WordPress before, you know you need to point to the backend database as well as provide an ID and password for the WordPress administrator. Pressing the Launch… button will walk you through the process of supplying that information, which ultimately gets incorporated into the wp-config.php file.
First off is the connection with the database; below is a diagram highlighting the correlation between the SQL Azure setup and what’s needed for WordPress. Note specifically that the WordPress User Name must be in the format user@servername, and you need to ensure that the SQL Azure instance will accept requests from WordPress by enabling the “Allow Microsoft Services access to this server” checkbox on the Firewall Settings tab (not shown).
Ok, now WordPress is talking to SQL Azure just fine, so the next step is setting up the WordPress site – providing a site title, username and password. Hopefully, it’s clear that this is all “WordPress stuff,” and you’d do this for any installation of WordPress regardless of host.
Press Install WordPress and you’re good to go! Go ahead and login to the WordPress dashboard and start creating content; I did! If you browse to
you should see a copy of this very post (presuming the account is still around when you check, that is!)
The Admin Tab
We briefly touched upon the Admin tab in the Windows Azure Companion when viewing the log entries showing the installation progress, but there’s a lot of additional functionality there as well:
- Windows Azure Logs – view the Windows Azure logs, specifically the entries in the WADLogs table of your Windows Azure storage account.
- PHP Logs – view the PHP error log.
- Configure Runtime – access configuration settings for MySQL and PHP.
- Cron Jobs – get list of the PHP cron jobs that are specified in the ProductListXmlFeed (see the schema documentation for how to set this up).
- Performance Monitor – sample CPU utilization and available memory based on the performance data collected and stored in the WADPerformanceCounters table in Windows Azure storage.
- Backup and Cleanup – manage the Windows Azure drive storage on which were installed WordPress, PHP, and whatever other applications you selected.
Hopefully it’s clear that the Window Azure Companion goes a loooong way to reducing the pain of installing PHP and related applications on Windows Azure. Since the options are controlled by an XML feed, adding Drupal, Joomla!, and other open source packages that have been vetted to work on Azure should be a simple matter.
That pretty much covers it. Remember, you have access to all the source code for the Windows Azure Companion, so check it out, add your own features, or contribute to the discussion on the MSDN CodeGallery.