Using Custom PHP Extensions in Windows Azure Web Sites

I’m happy to announce that with the most recent update to Windows Azure Web Sites, you can now easily enable custom PHP extensions. If you have read any of my previous posts on how to configure PHP in Windows Azure Web Sites (Windows Azure Web Sites: A PHP Perspective and Configuring PHP in Windows Azure Web Sites with .user.ini Files), you probably noticed one glaring shortcoming: you were limited to only the PHP extensions that were available by default. Now, the list of default extensions wasn’t bad (you can see the default extensions by creating a site and calling phpinfo() ), but not being able to add custom extensions was a real limitation for many PHP applications. The Windows Azure Web Sites team recognized this and has been working hard to add the flexibility you need to extend PHP functionality through extensions.

If you have used Windows Azure Web Sites before to host PHP applications, here’s the short story for how to add custom extensions (I’m assuming you have created a site already):

1. Add a new folder to your application locally and add your custom PHP extension binaries to it. I suggest adding a folder called bin so that visitors of your site can’t browse its contents. So, for example, I created a bin folder in my application’s root directory and added the php_mongo.dll file to it.

2. Push this new content to your site (via Git, FTP, or WebMatrix).

3. Navigate to your site’s dashboard in the Windows Azure Portal, and click on CONFIGURE.


4. Find the app settings section, and create a new key/value pair. Set the key to PHP_EXTENSIONS, and set the value to the location (relative to your application root) of your PHP extensions. In my case, it looks like this:


5. Click on the checkmark (shown above) and click SAVE at the bottom of the page.


That’s it. Any extensions you enabled should now be ready to use. If you want to add multiple extensions, simply set the value of PHP_EXTENSIONS to a comma delimited list of extension paths (e.g. bin/php_mongo.dll,bin/php_foo.dll).

Note: I’m using the MongoDB extension as an example here even though MongoDB is not available in Windows Azure Web Sites. However, you can run MongoDB in a Windows Azure Virtual Machine and connect to it from Windows Azure Web Sites. To learn more about how to do this, see this tutorial: Install MongoDB on a virtual machine running CentOS Linux in Windows Azure.

If you are new to using Windows Azure Web Sites to host PHP applications, you can learn how to create a site by following this tutorial: Create a PHP-MySQL Windows Azure web site and deploy using Git. Or, for more brief instructions (that do not include setting up a database), follow the How to: Create a Website Using the Management Portal section in this tutorial: How to Create and Deploy a Website. After you have created a website, follow the steps above to enable custom PHP extensions.

Enabling custom extensions isn’t the only nice thing for PHP developers in this update to Windows Azure Web Sites. You can now specify a custom version of PHP, you can publish from GitHub, and you can publish to a Windows Azure Web Site from a branch other than master. For more information on these updates, see the following articles/videos:



Comments (7)

  1. David Mack says:

    Thanks! Massively useful, I googled around all day not finding this answer.

  2. Whats with the standard php extensions in the php extension_dir like fileinfo which are not enabled by default? Is there a way to enable these extensions without copying them to the wwwroot dir.

    PS: Thanks too, very useful feature so far.

  3. Cory Fowler says:

    @DA6796CC-D2A0-44B0-BB89-D67A3BE6ABCB – Currently there isn't a way to enable items in the default ext folder. I have filed a bug with the team.

  4. Anonymous says:

    I include the php_sqlite3 dll into the "ext/" directory  and i load the extension via settings.ini file. Then i add via azure panel app setting the PHP_EXTENSIONS key. I restart my site and i receive this error message "Fatal error: Class 'SQLite3' not found". Please i need help. I try multple solutions. Wich is my error..

  5. Anonymous says:

    @CLenon – Would you mind expanding on your issue in a thread on stackoverflow, then reach out to me on twitter, my handle is @cfowlerMSFT.

  6. Ali says:

    The “Configure” option in point 3 above is no where to be found in Azure control panel. Where is this option?

    1. Larry Franks says:

      Hi Ali, this post is really old; the Azure portal has changed at least once since then, maybe twice. I recommend the official Azure docs at for the most up to date information on this.