Note:This article pertains to the CodePlex SDK initially released late 2009. The Windows Azure team has since then released a newer version of the Azure SDK for PHP on Github. Please refer to the Windows Azure PHP Developer Center for documentation on this more recent version of the SDK.
Please stay tuned and come back here regularly as we are working on refreshing the tutorials to deliver up to date and useful content for our PHP developers.
- Setup the Windows Azure development environment
- Setup the Windows Azure SDK for PHP
This article will show you how to use the scaffolding features of the Windows Azure SDK for PHP and the Drupal scaffold to quickly deploy an instance of Drupal optimized to run on Windows Azure.
This article assumes you have a Windows Azure development environment already setup on your machine. If you have not setup the development environment yet please see the articles listed in the Pre-Requisite to get your Windows Azure development environment setup.
Internet access is required for the Drupal scaffold to download several core components.
Windows Azure service setup
Before you will be able to run Drupal on Windows Azure you need to setup the following services:
- Hosted Service
- Storage account
- SQL Azure database
- Make sure you have created the database before proceeding
For more information on setting up these services see the following MSDN articles
Download the Drupal scaffold
A version of Drupal that is optimized to run on Windows Azure has been turned into a scaffold to allow for easy configuration and deployment to Windows Azure. The Drupal scaffold can be downloaded from:
The Drupal.phar file contains the packaged scaffold you need to run this tutorial. The source folder contains the source of the scaffold which you can download and alter as need requires.
Place the Drupal.phar file into C:\temp for easy reference during the remainder of this article.
Run the Drupal scaffold
When the Drupal scaffold is run an optimized version of Drupal will be built in a project location of your choosing, for this article we will be using C:\temp\Drupal.
The Drupal scaffold requires several parameters when being run. The values of the given parameters will be used to populate the ServiceConfiguration.cscfg file.
--DiagnosticsConnectionString - This is the credentials to login to your storage account and will be in the form of --DiagnosticsConnectionString="DefaultEndpointsProtocol=https;AccountName=*****;AccountKey=*****"
--sql_azure_database - The name of the database to put data into
--sql_azure_username - Valid username with credentials for the database. Should be in the form of user@db_host
--sql_azure_password - Password corresponding to the user account for the database
--sql_azure_host - The fully qualified path to your database server. If using SQL Azure it will be of the form db_name.database.windows.net
--sync_account - Endpoint of your Windows Azure storage account for file syncronization
--sync_key - Storage connection key for the sync storage account
Note: If you need to change the value of a parameter after running the scaffold you will not need to rerun the scaffold. Open the ServiceConfiguration.cscfg file for editing and you will see all the values you entered previously.
Create the project
The Drupal scaffold can be run with the following command:
scaffolder run -s="C:\temp\Drupal.phar"-out="C:\temp\Drupal" -DiagnosticsConnectionString="DefaultEndpointsProtocol=https;AccountName=****;AccountKey=****" -sql_azure_database=**** -sql_azure_username=**** -sql_azure_password=**** -sql_azure_host=**** -sync_account=**** -sync_key=****
Running the Drupal scaffold may take several minutes. There are several critical operations happening:
- A Drupal archive is downloaded and unpacked into the project directory
- The plugin for SQL Azure is downloaded and added to the project
- The Windows Azure Integration module is downloaded and added to the project
- Drupal is configured to work with Windows Azure services
- The Windows Azure service configuration file is setup
Open C:\temp\Drupal in a file browser and you should see the following files:
The Drupal files are located inside of the WebRole folder.
Install the Windows Azure FileSystemDurabilityPlugin
Drupal uses the FileSystemDurabilityPlugin to keep several key files synchronized across all running instances. It is a plugin to the Windows Azure SDK and is very easy to install.
The FileSystemDurabilityPlugin is hosted on Github. Just copy it into the Windows Azure SDK folder and configure it through the ServiceConfiguration.cscfg file before packaging.
- Download the FileSystemDurabilityPlugin from https://github.com/downloads/Interop-Bridges/Windows-Azure-File-System-Durability-Plugin/FileSystemDurabilityPlugin-v1.1.zip
- Copy the FileSystemDurabilityPlugin folder you just downloaded to C:\Program Files\Windows Azure SDK\<YOUR VERSION>\bin\plugins
- Edit C:\Temp\WordPress\ServiceConfiguration.cscfg with your settings for the FileSystemDurabilityPlugin
For more information see the readme file located at https://github.com/Interop-Bridges/Windows-Azure-File-System-Durability-Plugin
Drupal writes directly to the file system when themes and plugins are installed. This will work in Windows Azure, however changes written to the file system are not durable and will be erased when the instance is restarted or upgraded. Also the file system is not shared across instances so if there are multiple instances running on the same Drupal installation they will not know of any changes made to the file system by any other running instance. Therefore the proper method of adding themes and plugins is to do it now before it is packaged and uploaded.
If you desire to upgrade or add additional files later it is recommended that the files be added to the project files on the development machine and Drupal repackaged.
Custom php.ini settings
If you need to add or change custom settings in the php.ini file this scaffold has support for that. Open the WebRole directory and you will find a php directory. Inside of that directory is a php.ini file. Whatever settings exist in here are automatically added to the installed PHP's php.ini at runtime.
Additionally if you have extension you would like to run they may be added to the ext folder and setup in the php.ini. All files in the ext folder are copied to the installed PHP's ext folder at runtime and will be available for use.
Package the Drupal project
When you are finished customizing your Drupal installation you will need to package the project to deploy. The following command will create the package:
package create -in="C:\temp\Drupal"-out="C:\temp"-dev=false
Deploy the Drupal package
You now need to deploy the package files to Windows Azure to get the Drupal site running. If you have not deployed a Windows Azure package see the following articles:
Finalize the Drupal installation
The final step is to visit the URL you chose when creating the Hosted Service which the Drupal package is deployed on. When you visit the URL you will be presented with the standard Drupal form to fill in the details about your site and initial login information.
Go to http://[yourSite]/install.php
Setup the storage module
Once Drupal is installed, you need to enable and configure the blob storage module that uses Windows Azure blob storage for storing media files. Use following instructions to configure it correctly.
- Step-1) Login as admin and click on modules tab and enable
Azure Storage module. This will ask confirmation to enable
dependent ctools module.
- Step-2) Click on Configuration tab and then click on Azure Storage in the Media section. Click on "Add" button.
- Step-3) Provide details as follows the dialog. Please provide a
name that does not contain whitespace or non-ASCII character.
Provide the name of an existing container, this container must be
public. (The Azure Storage
Explorer can be used to create and manage storage)
- Step-4) Again click on Configuration tab and then click on "File System" in the Media section.
- Step-5) Check radio button "Files stored on Azure Blob Storage"
and click on "Save Configuration" button.
- Step-6) Click on "Structure"->"Content Type". Then click on
"manager fields" for "Article" type. Ensure that following path
will be displayed.
Home » Administration » Structure » Content types » Article
- Step-7) Click on "Edit" button in the "OPERATIONS" column for