Deploying Your First PHP Application to Windows Azure

Author: Jas Sandhu

Date: Monday, December 27, 2010, 12:00:00 AM

Tags: Get Started, Deploy, Portal

Table of Contents

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.

Setting up a Windows Azure Account

To get your PHP application running on Windows Azure you will need a Windows Azure subscription.

If you don't have one, you can create one here: (You'll need a Windows Live ID to sign up.) ; You may choose the Windows Azure Platform Introductory Special, which allows you to get started for free as long as you limit your usage. ; (For complete pricing details, see ; After you purchase your subscription, you will have to activate it before you can begin using it (activation instructions will be provided in an e-mail after signing up).

New Windows Azure Portal

Windows Azure has recently updated the management portal to a much improved user interface (Silverlight based). ; If you decide not to use the new version, you can still go back to the "old" portal. ; But note that the "old" version will be shut down sometime in early 2011.

This tutorial shows how to use both versions:

Deploying your first PHP application with the old Windows Azure portal

Once you have a Windows Azure subscription, you need to create a hosted service. ; To do this, go to the Windows Azure developer portal, and click on New Service:


If this is not your first time using Windows Azure, your screen may look like different. ; If so, click on your project name, then New Service:


Now select Hosted Services:


Then provide a Service Label and Service Description:


Also provide a URL and specify the region in which you want to create the service:


Then click Create. Your service should be created shortly.

Now click Deploy:


Now your service is ready, it's time to upload the package that has been built earlier.
You can rebuild your deployment by running the following command:

c:\Program Files\WindowsAzureCmdLineTools4PHP>php package.php --project=PHPInfo --phpRuntime="C:\Program Files\PHP" --source="%TMP%\PHPInfo" --defaultDoc=info.php

The only difference is that this time, we don't use the "--RunDevFabric" parameter. ; Once the command is executed, you should get this:


The deployment package and configuration is ready and the command line tool tells you where to get it. ; Note that you have the option to specify where you want the package to go, by using the argument:


Browse to the application package (.cspkg) and configuration settings (.cscfg) files in your project subdirectory:


If you have followed the tutorial to the letter, you can navigate quickly to your working directory by typing "%TEMP%" in the File Name entry, and hit enter:


Then go to the "WACmdLineTools\PHPInfo_Build\PHPIndo" directory:


Choose a label for the deployment, and click Deploy:


It will take a few minutes for your application to deploy.


When your application has deployed, click Run.


It will take several more minutes for your application to be available (It will go through phases of "Initializing", "Busy", and finally "Ready"):


When you click on the Web Site URL provided, you should see your application running in the cloud:


Congratulations, you have built your first Windows Azure cloud application!

Deploying your first PHP application with the new Windows Azure Portal

The main interface looks like this. Click on "New Hosted Service" to deploy your PHP application:


Then provide the information about your deployment:

When you click OK, you may see a warning: This deployment has at least one role with only one instance. We recommend that you deploy at least two instances per role to ensure high availability in case one of the instances becomes unavailable.

For testing purpose, you may ignore the warning.

Your package is now being deployed:


Once the deployment is done, your application is ready to use on the staging environment. ; You can test it by clicking on the "DNS name" link.


If you want to switch to the production environment, just select the deployment and click "Swap VIP".


Now, you should see this:


Congratulations, you have built your first Windows Azure cloud application!

What's next?

blog comments powered by Disqus

Related Content

No related content was found