Installing PHP on Windows Azure leveraging Full IIS Support: Part 3

By: Cory Fowler, February 28, 2011

In my last two posts in this series [Part 1, Part 2] we have created a Start-up script to install PHP on our Windows Azure Web Role, we have created the necessary Cloud Service Definition and Cloud Service Configuration files.

In this post we’ll look at how to use the command-line tools for Windows Azure to Package our Deployment and how to deploy that package to the Windows Azure Platform Portal.

Packaging a Windows Azure PHP Deployment

I know what you’re thinking “Hold up, we need to package our deployment? What ever happened to good old FTP?”

FTP works great for a single point of access, but we’re looking to be able to rapidly deploy our application across many servers in a matter of minutes. Microsoft uses these packages for just that purpose, rapid deployment.

What is the Cloud Service Package (.cspkg)

The Cloud Service Package is essentially a Compressed file which holds your application, the Cloud Service Definition and a number of other files required by Windows Azure. These files are encrypted by the tool incase the package is intercepted when being transported over HTTP.

You are able to leave the cspkg unencrypted using one of two methods. I would suggest using the Environment Variable [setting _CSPACK_FORCE_NOENCRYPT_ to true], mostly due to the fact that there is a good chance you won’t be using MS Build for your PHP Application.

Setting an Application Variable

Open the Control Panel. Find and Click on System.

set environment variables

Click on the Advanced System Settings link in the Right hand Menu. This will open the System Properties Dialog.

image

Click on Environment Variables…

image

Then on New…

image

Creating a Build Script to Automate Deployment Packaging

As a developer, it is a good idea to optimize repetitive tasks in order to be more productive. One of these optimization points that you should be looking at is Build Automation. With PHP being a Scripting Language and does not need to be compiled this is a very simple thing to accomplish. Here is how simple your “Build Script” can be.

cspack ServiceDefinition.csdef

In our previous post we added the Windows Azure Command-Line Tool Path to our System Path. This enables the above script to execute the tools and create the Cloud Service Package.

To make your build script more powerful, you could add some additional functionality like executing a powershell script which leverages the Windows Azure Powershell CommandLets to deploy your latest Build to your Staging Environment in Windows Azure.

Deploying your Service Package to Windows Azure

There are many different means to getting your Windows Azure Project in to the Cloud. Once you’ve had a chance to evaluate the different methods I would suggest using the method that you find most suitable for you.

Here is a list of different methods of Deploying to Windows Azure:

Note: Barry Gervin and I have put together a video on how to deploy using the Windows Azure Platform Portal.

  • Deploying using Visual Studio

Test Startup Scripts Locally using RDP

As developers we all know that testing will always win out over trial and error, this is no different when creating a startup script for Windows Azure. Be sure to save yourself from pulling out your hair by testing you’re the executable files that will be called by your start-up tasks by RDPing into a Compute Instance.

I’ve created a few blog posts that will aid you in setting up RDP into Windows Azure:

Note: Installers that have a “Quiet Install” option (/q) in their command-line switches, are your absolute best friend. Otherwise, trying to mimic a users acceptance to a Eula or other dialog is rather difficult. WebPI allows us to accept a Eula with a switch (/AcceptEula)

[This article also appears on SyntaxC4's Blog.]

Tagged with: , , , ,
Posted in Miscellaneous

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Avatar of Cory Fowler

Cory Fowler

What people are saying about #webnotwar

Look! Its @fharper and @jollfr talking about open source and the cloud at #S2LQ! #webnotwar pic.twitter.com/iWqdcYRaHF

Retweeted by Jonathan Le Lous

Microsoft & Savoir Faire Linux en grande discussion au #s2lq #webnotwar @ Espace Dalhousie instagram.com/p/tDVTP2itka/

Microsoft & Savoir Faire Linux en grande discussion au #s2lq #webnotwar
Retweeted by Laurent Bounin

Look! Its @fharper and @jollfr talking about open source and the cloud at #S2LQ! #webnotwar pic.twitter.com/iWqdcYRaHF

Retweeted by Laurent Bounin

Look! Its @fharper and @jollfr talking about open source and the cloud at #S2LQ! #webnotwar pic.twitter.com/iWqdcYRaHF

Microsoft & Savoir Faire Linux en grande discussion au #s2lq #webnotwar @ Espace Dalhousie instagram.com/p/tDVTP2itka/

Microsoft & Savoir Faire Linux en grande discussion au #s2lq #webnotwar

Bonjour Québec! Tellement excité à propos de #S2LQ! Je vous demande d'excuser mon français; ce n'est pas ma langue maternelle :) #webnotwar Retweeted by Laurent Bounin

Bonjour Québec! Tellement excité à propos de #S2LQ! Je vous demande d'excuser mon français; ce n'est pas ma langue maternelle :) #webnotwar

@mgifford likewise! Good to meet. Look forward to making #webnotwar together!

Hellllllo Montreal! Spreading #opengov and #opensource goodness makes me "Feel So Good"! #webnotwar @… instagram.com/p/tCIfVmOJIP/

Hellllllo Montreal! Spreading #opengov and #opensource goodness makes me "Feel So Good"! #webnotwar

Join the conversation about empowering young women in politics with @headstartottawa #ogt14 #webnotwar pic.twitter.com/Z1kJrrTPAW

Retweeted by Jacques Mailloux

Thank you Ottawa for rocking #OGT14! Now we are off to Quebec for #S2LQ! #webnotwar #opendoesntsleep @… instagram.com/p/tCADH_uJP9/

Thank you Ottawa for rocking #OGT14! Now we are off to Quebec for #S2LQ! #webnotwar #opendoesntsleep
Retweeted by Jacques Mailloux

Thank you Ottawa for rocking #OGT14! Now we are off to Quebec for #S2LQ! #webnotwar #opendoesntsleep @… instagram.com/p/tCADH_uJP9/

Thank you Ottawa for rocking #OGT14! Now we are off to Quebec for #S2LQ! #webnotwar #opendoesntsleep
Retweeted by Make Web Not War

Join the conversation about empowering young women in politics with @headstartottawa #ogt14 #webnotwar pic.twitter.com/Z1kJrrTPAW

Retweeted by Craig Carter-Edwards