In this lab, use Windows Azure Toolkit for Eclipse to build, package and execute a simple PHP application as a Windows Azure Service running on the local development fabric. You will also learn about deploying simple PHP Windows Azure project as a packaged application to the Windows Azure cloud.
This lab will not address any of the Windows Azure Storage functionalities.
Before doing this lab, if you not done so:
In this task, you will create a basic PHP Web project that will be used within a Windows Azure Web Site.

In Data Storage Options, select None.
This selection means that no Windows Azure Storage functionality will be configured into this new project.
Note that in the PHP Explorer, examine the structure of the created solution.
Two PHP projects have been created:
When creating a PHP Windows Azure Web project without Windows Azure Storage functionality configured, Windows Azure Toolkit for Eclipse provides a solution that ready to run in both the Development Fabric and within the Windows Azure Cloud.
In this task, you are going to understand what are the contents a default PHP Windows Azure Web project.
The toolkit's default basic Web Role project is a standard PHP Web application project template that has been modified to work with Windows Azure.
The Web Role project for this lab is HelloAzure_WebRole
The toolkit's default contents of a basic Web Role project are:
| XML — web.config — Default Document | |
|---|---|
<!-- Example WebRole IIS 7 Configation --> <defaultDocument> <files> <clear/> <add value="index.php"/> </files> </defaultDocument> | |
Enables module IIS FastCGI to deploy and run applications written with PHP.
| XML — web.config — PHP handler | |
|---|---|
<handlers>
<clear/>
<add modules="FastCgiModule"
name="PHP via FastCGI"
path="*.php"
resourceType="Unspecified"
scriptProcessor="%RoleRoot%\php\php-cgi.exe"
verb="*" />
<add modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
name="StaticFile"
path="*"
requireAccess="Read"
resourceType="Either"
verb="*" />
</handlers>
| |
The toolkit's default basic Service project contains definition and configuration to run the Web Role in the Development Fabric and the Windows Azure Cloud.
The Service project for this lab is HelloAzure.
ServiceDefinition.csdef contains the metadata needed by the Windows Azure fabric to understand the requirements of your application, such as which roles are used. It will also contain configuration settings that apply to all instances. These configuration settings can be read using the Windows Azure API as you will see in a later exercise.
The Web Role element describes a role that accepts external requests via HTTP and/or HTTPS endpoints.
InputEndpoints — Describes a collection of input endpoints for the web role.
It holds a single service endpoint the service receives requests to a web role.
The toolkit sets by default the transport protocol to http and port to 80.
| XML — ServiceDefinition.csdef | |
|---|---|
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition
name="HelloAzure"
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole" enableNativeCodeExecution="true">
<ConfigurationSettings>
</ConfigurationSettings>
<InputEndpoints>
<!-- Must use
port 80 for http
and port 443 for https
when running in the cloud -->
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</InputEndpoints>
</WebRole>
</ServiceDefinition>
| |
ServiceConfiguration.cscfg contains values for configuration settings as defined by ServiceDefinition.csdef, and the number of instances to run for each role.
ServiceConfiguration element's attribute serviceName — Specifies the name of the service. The name must match the name provided in the service definition file.
The created project has set its value to HelloAzure.
Instances element — Specifies the desired number of role instances of the service, as well as the minimum number required for the service to operate.
The toolkit sets by default Instances with value of 1.
| XML — ServiceConfiguration.cscfg | |
|---|---|
<?xml version="1.0" encoding="UTF-8"?>
<ServiceConfiguration
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"
serviceName="HelloAzure">
<Role name="WebRole">
<ConfigurationSettings/>
<Instances count="1"/>
</Role>
</ServiceConfiguration>
| |
In this task, you will run your service locally in the Development Fabric.
You will modify the index.php page, then build and execute the Web Role in the Development Fabric.
| PHP — index.php | |
|---|---|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Windows Azure PHP Info</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> </head> <body> <h1>Windows Azure PHP Info</h1> <h2>PHP Information</h2> <p> <?php phpinfo(); ?> </p> </body> </html> | |
Note that a Web Role's default document index.php can be set in two locations.
| XML — web.config | |
|---|---|
<?xml version="1.0"?>
<configuration>
<system.webServer>
<!-- ... -->
<!-- Example WebRole IIS 7 Configation -->
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
| |
To set the number of Web Role deployments to 2 when Windows Azure service starts:
| XML — ServiceConfiguration.cscfg | |
|---|---|
<?xml version="1.0"?>
<ServiceConfiguration
serviceName="HelloAzure"
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" >
<Role name="WebRole">
<Instances count="2"/>
<ConfigurationSettings>
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
| |

Note: |
|---|
| This will show you the roles and ports that were requested and issued. If this is the first instance running, you should see a URL of http://*:80 and an IP Address of 127.0.0.1:80. When you execute a Windows Azure service, it will try to allocate the port specified in the ServiceDefinition.csdef file. If this port is not available, the next available port is used. |
In this task, you will run your service remotely on Windows Azure using a Windows Azure Storage Account.
Note: |
|---|
|
This task requires that you to have a developer account. To register for an account, please visit: Account — Windows Azure Platform. |
Note: |
|---|
|
This task does not present a thorough presentation of deploying Service Packages to Windows Azure Cloud. This task only presents a need to know based upon using Eclipse for Windows Azure. For a thorough tutorial on deploying Service Packages, read: Deploying a Service on Windows Azure For Eclipse for Windows Azure users, in the tutorial ignore the prerequisite to read Visual Studio walkthrough since it pertains to C# Service Packages. |
There are two ways to create a Service Package and deploy this package to the Windows Azure Cloud:
Here the creating and publishing or Service Package are separate steps.
This process can be performed either of the following ways...
This action will open a portal to Windows Azure, which will be gone in more detail later in this lab.
Here the creating and publishing or Service Package are combined into a single action.
This process can be performed either of the following ways...
Note: |
|---|
|
No Combo does not included fries or soft drink! |
This action will open a portal to Windows Azure, which will be gone in more detail later in this lab.


Note the newly create additions to this project...
Note: |
|---|
|
In the deployment within Windows Azure portal, both of these files will be requested:
|
Note: |
|---|
|
What is a Service Package?
|
Note: |
|---|
|
Note in the bottom right-hand corner that the number of deployments are 2. |
In this task, you will clean up worked performed on Windows Azure.
To delete deployments in Development Fabric, either:
To delete deployments in Windows Azure Cloud:
In this lab, you have learned how to...