Installing PHP on Windows Azure leveraging Full IIS Support: Part 3
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.
Click on the Advanced System Settings link in the Right hand Menu. This will open the System Properties Dialog.
Click on Environment Variables…
Then on New…
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.
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:
- Using the Powershell CommandLets
- Using the MMC Snap-in
- Deploying using the Windows Azure Platform Portal
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:
- Exporting & Uploading a Certificate to an Azure Hosted Service
- Setting up RDP to a Windows Azure Instance: Part 1
- Setting up RDP to a Windows Azure Instance: Part 2
- Connecting to a Windows Azure Instance via RDP
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.]
- Inspirational Quotes About Computer Programming 92 views
- Feeling Blue? Why The Most Popular Websites Are Blue 20 views
- Creating PHP CRUD Apps with SQL Server on your Server or in the Azure Cloud 12 views
- Collection of Open Gov & Open Data Memes 9 views
- Deploying a Java application to Windows Azure with Command-line Ant 7 views