Windows Azure - PHP contributions


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:

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"?>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          <filter type="" />
    <defaultDocument enabled="true">
        <clear />
        <add value="index.php" />
        <add value="default.php" />
      <add name="PHP via FastCGI"
           resourceType="Unspecified" />

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 6:32 PM by maartenba, version 3


aurelious Dec 14, 2011 at 2: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