Windows Azure came up with a new SDK update “Windows Azure SDK 1.6″.

In our case it brought a lot of hair tearing chances with it. Because so far we developed our PHP application with eclispe and the out-dated  windowsazue4e Plugin.

Eclipse presetting for the folder structure was like this:

|_ ServiceDefinition.csdef
|_ ServiceConfiguraion.cscfg
|_ ServiceDefinition.csx (Development approot folder)
|_ WindowsAzurePHPApp.cspkg (Package file)

|_ php
|_ Web.config
|_ Web.roleconfig
|_ index.php

Whereas the new scaffolding advices the following structure:

|_ ServiceDefinition.csdef
|_ ServiceConfiguraion.cscfg
|_ WebRole
|_ build
|    |_ [Local dev. package files]
|_ pack [Package files]
|    |_ WindowsAzurePHPApp.cspkg
|    |_ ServiceConfiguraion.cscfg
|_ php
|    |_ [The whole PHP libs]
|_ bin
|    |_ [Start up scripts]
|_ index.php

Command to run the development build:

package create -in="C:\temp\WindowsAzurePHPApp"
   -out="C:\temp\WindowsAzurePHPApp\build" -dev=true

Command to generate the cloud package:

package create -in="C:\temp\WindowsAzurePHPApp"
   -out="C:\temp\WindowsAzurePHPApp\pack" -dev=false


Preparing everything:

  1. Get the Windows Azure SDK
    The best way is it to use the Windows Web Platform Installer. Follow step by step the instructions here.
  2. Get the new WindowsAzure for PHP SDK.
    Set it up step by step using the instructions here.
    If you use classes from this SDK within your project you should also put a copy into your project itself.

What to change after the SDK update:

  1. Generate a sample project:
    To have a clean sample project for copying the needed parts to the our project we generate it by using the new scaffoldig functionality of the WindowsAzure for PHP SDK:
    Open the command line and run: 

    scaffolder run -out="C:\temp\WindowsAzurePHPApp"

    Now we have clean and simple sample project.
    Test everything by following these steps.

  2. Move the sources into the new folder structure:
    Rebuild the sample structure for our project and move your files into it.  

    • Replace the php-folder with the php folder in c:\program files\PHP\v5.3 (installed with the Web Platform Installer) and edit the php.ini with your settings.
      Set the xtension directory to: 

    • Replace the old bin-folder with the bin folder of the sample project.
    • Edit the PHP-paths within cmd-scripts in the bin-folder.

  3. ServiceDefinition.csdef configuration:
    • Add the Sites-Element.
    • Add the Startup-Element for the PHP installation.
    <?xml version="1.0" encoding="UTF-8"?>
    <ServiceDefinition name="WindowsAzurePHPApp" xmlns="">
      <WebRole enableNativeCodeExecution="true" name="WebRole" vmsize="ExtraSmall">
          <Site name="Web" physicalDirectory="./WebRole">
              <Binding name="HttpIn" endpointName="HttpIn" />
          <Task commandLine="add-environment-variables.cmd" executionContext="elevated" taskType="simple" />
          <Task commandLine="install-php.cmd" executionContext="elevated" taskType="simple">
              <Variable name="EMULATED">
                <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
          <Task commandLine="monitor-environment.cmd" executionContext="elevated" taskType="background" />
          <InputEndpoint name="HttpIn" port="80" protocol="http"/>
  4. ServiceConfiguraion.cscfg configuration:
    Add the osFamily and osVersion attributes: 

    <ServiceConfiguration serviceName="Stats" xmlns="" osFamily="2" osVersion="*">
  5. Web.config configuration:
    • Remove the Handlers-Element for PHP via FastCGI (By now on this will be handled by the startup scripts)


Important changes with the new SDK:

  • $_SERVER['RoleRoot'] doesn’t exist anymore.
  • $_SERVER['INSTANCE_ID'] doesn’t contain a local Instance number like “1″ or “2″ anymore. It seams that it’s now a global number like “16325987″.
    Alternativly you can use [RoleInstanceID] => WebRole_IN_0.
  • $_SERVER['TEMP'] is not the same drive like the accessable local storage any more, so you can’t use it to locate the current letter of the accessable this drive. I don’t know if it’s always “c:\“.
  • The PHP method azure_getconfig(‘StorageAccountName’) does not exist anymore. This method could be used to get the setting values of the ServiceConfiguration.cscnf.
    Even if I copy the php_azure.dll of the old project into the new one and enabling the extension (extension=php_azure.dll) in th ephp.ini, it does not work.
  • The file Web.roleconfig is deprecated.