Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Windows Azure, PHP, ...

About the author

Maarten Balliauw is currently employed as .NET Technical Consultant at RealDolmen. His interests are mainly web applications developed in ASP.NET (C#) or PHP and the Windows Azure cloud platform.
More about me More about me
Send mail E-mail me


ASP.NET MVC Quickly Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn
View Maarten Balliauw's MVP profile

Search

Latest Twitter

    Follow me on Twitter...

    Archive

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright Maarten Balliauw 2012


    Accessing ServiceConfiguration in FastCGI (PHP) web role

    While working on a sample PHP application hosted on Windows Azure, I found that it is nearly impossible to retrieve information from the Windows Azure ServiceConfiguration.cscfg file. Also, it is impossible to write log messages to the Windows Azure Web Role. Well, both are not 100% impossible: you can imagine dirty hacks where you let a ASP.NET page do something from PHP and stuff like that. But how about a clean solution? How about… A PHP extension module?

    kick it on DotNetKicks.com

    I’ll not be going into detail on how this module was built, but there is a native C++ RoleManager implementation in the Windows Azure samples. Using the resources listed below, I managed to create a PHP extension module, wrapping this RoleManager. The result? You can now retrieve configuration values from the ServiceConfiguration.

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

    // etc.

    Next to this, logging is now also exposed: simply call azure_log() and you’re done:

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

    // etc.

    Oh, you want to have the path where a localStorage is available? (see here for info)

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

    // etc.

    Want to use it in your own PHP applications hosted on Windows Azure?

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

    Downloads

    Resources

    The following links have been helpful in developing this:

    kick it on DotNetKicks.com


    Categories: Azure | General | PHP

    Comments (2) -

    Juliën Netherlands |

    Tuesday, August 04, 2009 11:57 AM

    Juliën

    Great solution. But using a C++ (un?)managed library... in php... to access azure xml config files. *Shivers* that this is way it's got to be ;)

    maartenba Belgium |

    Tuesday, August 04, 2009 12:45 PM

    maartenba

    Better than my first take (not blogged) where I was calling a .aspx page to retrieve data.

    Anyways, FastCGI is about unmanaged code, so nothing wrong with this approach.

    Pingbacks and trackbacks (1)+

    Comments are closed