our wordpress live sample website：
Download sample project here
This tutorial article will show you how to consume SQL Azure using PHP with just several easy steps. Please refer first series article Run PHP application in Windows Azure for a prerequisite.
1. To enable PHP to access SQL Azure, SQL Server Driver must be added to PHP extensions. (For SQL Azure is built on SQL Server).Download it form SQL Server Driver for PHP 2.0.
2．Open and extract it, driver files are listed below.
We choose php_sqlsrv_53_nts_vc9.dll, for it matches our PHP version, VC9 x86 Non Thread Safe.
Put the driver into php\ext folder in the PHP_WebCgiRole project.
Rename php.ini-develop in the php folder to php-ini. Right click on php.ini, choose Properties, and change the value of Build Action to Content.
Click to Open php.ini, look up extension_dir and change its value to "./ext". It indicates the extension directory of PHP.
Add "extension = php_sqlsrv_53_nts_vc9.dll "to php.ini.
4. Put the PHP code below to index.php (refer to Run PHP application in Windows Azure ) .Please refer to here to replace the SQL Azure account information with yours.
$serverName = "tcp:ServerID.database.windows.net, 1433";
$connectionOptions = array("Database" => "yourdatabase",
"UID" => "yourusername@ServerID",
"PWD" => "yourpassword",
$retry = 10;
$conn = sqlsrv_connect($serverName, $connectionOptions);
echo "Connect Success!";
if($conn === false)
5. Press F5 to debug the application, wait for the browser to start, you'll see the result below:
You can put it into Windows Azure Hosted service now, and will get the same result.
The process is still simple and easy as before, now you can exploit the power of SQL Azure!
Chapter 1: Using PHP application in Windows Azure
This article will show how easy to run PHP application inWindows Azure
Chapter 2: Consume SQL Azure Using PHP
This article describes how to access SQL Azure using PHP.
Chapter 3: Host Wordpress on Windows Azure
This article describes the process about host Wordpress on Windows Azure. Similarly, you will see how easy it will be.
Chapter 4: Using Windows Azure Storage in Wordpress
This article introduces the Windows Azure Storage plugin for WordPress . It enables Wordpress store multimedia contenton Windows Azure Storage.
Hi, your link for SQL Server Driver for PHP seems broken.
You may want to change to this updated link:
Thanks for your input.
we have updated the link.
I follow your tutorial, and pass through Chapter 1.
But I stuck at Chapter 2. I got 3 error popups when I hit F5.
"php-cgi.exe - Entry Point Not Found
x The procedure entry point php_set_error_handling could not be located in the dynamic link library php5.dll."
"php-cgi.exe - System Error
x The program can't start because php_pdo.dll is missing from your computer. Try reinstalling the program to fix this problem."
x The program can't start because php_mbstring.dll is missing from your computer. Try reinstalling the program to fix this problem."
I carefully recheck again, and try to remove some code in index.php.
I found that if I remove "sqlsrv_connect($serverName, $connectionOptions);" the problem was gone.
Do you have any idea?
I'm sure that SQL Azure account information is correct because I can connect to my database using Microsoft SQL Managment Studio.
and I have new infos.
when index.php don't have "$conn = sqlsrv_connect($serverName, $connectionOptions);" then I got blank page. no error.
then if insert "$conn = sqlsrv_connect($serverName, $connectionOptions);" then I got the 3 error popups. and "Http 500 Internal Server Error"
then if I change "$conn = sqlsrv_connect($serverName, $connectionOptions);" to
" sqlsrv_connect($serverName, $connectionOptions);" then I got "Http 500 Internal Server Error", no the error popups.
PS. I use SDK 1.3 and I need to comment <Sites> section in ServiceDefinition.csdef because of a error which discuss here
I still stuck in Chapter 2. T T
I add 2 more extensions in "php-ini" file
and the 3 error popups has gone.
BTW I still got "Http 500 Internal Server Error" page.
I also try the sample project, and It's doesn't work.