John Hoerr John Hoerr - 20 days ago 5
PHP Question

Sporadic error when loading PHP extension in Azure App Service

We have an Azure App Service that makes use of the Redis PHP extension. Both the App Service and extension are PHP 5.6 / 32-bit. We are loading the PHP extension from a

settings.ini
in accordance with the Azure documentation.

extension = "d:\home\site\wwwroot\ext\php_redis.dll"


Once every few weeks the App Service will fail to load the extension and the site breaks. We receive the following error in our logs:


[06-Nov-2016 17:25:42 America/Los_Angeles] PHP Warning: PHP Startup: Unable to load dynamic library 'd:\home\site\wwwroot\ext\php_redis.dll' - %1 is not a valid Win32 application.
in Unknown on line 0


This problem will go away on its own some hours later, presumably when the app service restarts or is migrated to another VM. We have an identical 'secondary' app service in a different region that never exhibits this problem.

Has anyone seen this sporadic failure? How can it be prevented?

Answer

The error message which can be caused in some unexpected condition that the file path is formed properly, for example, when there is file storage failover, auto-healing, etc. We had tested installing php_redis.dll from application settings instead of PHP_INI_SCAN_DIR, this way php.ini will be modified to include the extension path. This change can mitigate the issue.