This project is read-only.

Windows Azure - PHP contributions

php_azure.dll

Registering the extension

  • Download the php_azure.dll and make sure you have it in your /path/to/php/ext folder
  • Register the extension in php.ini:
extension=php_azure.dll

Getting configuration values from ServiceConfiguration.csdef

The "azure_getconfig" method can read configuration values from ServiceConfiguration.csdef. Some examples:

$appName = azure_getconfig(“AppName”); 
$storageAccount = azure_getconfig(“StorageAccount”);

Logging to the Azure Services Platform

Logging to the Azure Services Platform can be performed using the "azure_log" method. Some examples:

azure_log(AZURE_LOG_INFORMATION, “This is cool!”); 
azure_log(AZURE_LOG_CRITICAL, “Critical errors are not cool…”);

Important note: Make sure you have a trace listener registered in Web.config. An example:
<?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.webServer>
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="index.php" />
        <add value="default.php" />
      </files>
    </defaultDocument>    
    <handlers>
      <add name="PHP via FastCGI"
           path="*.php"
           verb="*"
           modules="FastCgiModule"
           scriptProcessor="%RoleRoot%\approot\php\php-cgi.exe"
           resourceType="Unspecified" />
    </handlers>
  </system.webServer>
</configuration>

Getting the path to localStorage

Getting the path to localStorage can be performed using the "azuregetlocalresourcepath" method. The maximal size can be retrieved usign the "azuregetlocalresourcepathsize" method. Some examples:

$rootPath = azure_getlocalresourcepath('teststore');
$pathMaxSizeInMb = azure_getlocalresourcepathsize('teststore');

Known issues

It is possible that you see the following error when running PHP with php_azure.dll enabled inside IIS or as a standalone application:
The program can't start because Diagnostics.dll is missing from your computer. Try reinstalling the program to fix this program.

The reason for this is that the php_azure.dll expects the Windows Azure Development Fabric as its host environment. This means that running PHP inside the Windows Azure Development Fabric will not yield this error.

If you do require standalone PHP to be working, add the following to your PATH environment variable:
PATH=C:\Program Files\Windows Azure SDK\v1.xx\bin\runtimes\base\x86;

Last edited May 5, 2010 at 7:32 PM by maartenba, version 3

Comments

aurelious Dec 14, 2011 at 3:34 PM 
How can I fix the Diagnostics.dll problem exactly? I tried zu reinstall the SDK etc. but the message still appears. I think thats the reason for that issue http://phpazurecontrib.codeplex.com/workitem/21877.