Another of those “learn from my mistakes” moments: Azure Web Sites don’t include the SQL Server PDO extension if your site is running PHP 5.5.
This I learned the hard way today.
I set up my site to run PHP 5.5.11, the version that as of this writing Azure uses. But my script halted without warning; knowing from experience that this meant there was a PHP error, I quickly popped into my site’s log and saw this entry:
[23-Jun-2014 12:52:36 America/Los_Angeles] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Program Files (x86)\PHP\v5.5\ext\php_sqlsrv.dll' - The specified module could not be found.
This clearly indicated that the PDO driver for SQL Server wasn’t present. And sure enough, a call to phpinfo() verified as much:
By switching back to version 5.4 — which is what Azure will load by default, if you don’t select a different one — the sqlsrv PDO driver was loaded:
Again, it’s worth noting that Azure will use PHP version 5.4.23 if you don’t specify which version of PHP you want to use. And you can set PHP versions — as well as versions of other scripting languages — in the Configure panel of your website’s dashboard:
It’s also worth noting that you can load custom DLLs in Azure hosting, or use a custom PHP runtime, so I could have added the sqlsrv DLL, or built a version of PHP 5.5 with the SQL Server PDO driver, if I really needed version 5.5.
Finally, if you want error reporting in PHP, that can be configured via a .user.ini directive.
All links in this post on delicious: https://delicious.com/dougvdotcom/protip-microsoft-azure-doesnt-sql-server-pdo-support-php-version-5-5