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: http://www.microsoft.com/windowsazure/offers/ (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 http://www.microsoft.com/windowsazure/pricing/.) ; 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:

clip_image001

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:

clip_image002

Now select Hosted Services:

clip_image003

Then provide a Service Label and Service Description:

clip_image004

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

clip_image005

Then click Create. Your service should be created shortly.

Now click Deploy:

clip_image006

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:

clip_image007

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:

--target="C:\AnyDirectory\"

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

clip_image008

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:

clip_image009

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

clip_image010

Choose a label for the deployment, and click Deploy:

clip_image011

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

clip_image012

When your application has deployed, click Run.

clip_image013

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

clip_image014

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

clip_image015

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:

clip_image016

Then provide the information about your deployment:
clip_image017

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:

clip_image018

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.

clip_image019

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

clip_image020

Now, you should see this:

clip_image021

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