Laravel 5, Azure and MS-SQL

Alright, this has proven to be quiet a mission for me. Turns out that I was kind of blind and didn't spot the obvious (No I won't explain what it was, all you need to know is that it was rather stupid).So after my "eureka" moment- I was able to find happines quickly.

This is going to be a quick run through- so make sure you cover all the bases before we begin. Here is what you should know before:

  • You know how to install Laravel on Azure part 1... you will need one install for this tutorial.
  • You know your way around setting up the environment in Laravel part 2 - again you'll need to work on this again.
  • You have already set up a MS SQL Database on Azure - and yes, have the details handy :)

As I've pointed out before- this will be a quick one. So here we go:

At this stage, I assume that you have at least a basic Laravel installation going as an Azure Web-App and the Database and the Site Admin Tools installed (again, if you don't know what I'm talking about here- have a look at part1 of my Laravel and Azure posts.

  • start the Site-Admin Tools and navigate to the console console

  • navigate to the database config file console

hit the edit button.

  • hit the edit button, and the editor comes up. It should look something like that:


So- you have a couple of options here. You could could pick the elegant way and define a variable in your environment for the database engine- or you can do it like I've done here (quick and dirty) and edit the file to tell it that it should use the mssql driver.

Update: Microsoft has just recently updated the PDO Drivers so newer versions of PHP can be used (e.g. 5.6) - I haven't tested this yet. If stuff fails, fall back to 5.4 (this is working fine)

Ok, once you have one these changes,- configure your .env file the same way. Navigate one level up and edit the .env file the way you did before:


Fill in your database details. As you can see in the host configuration you can see port number in after the comma. By the way, this is another common pitfall when configuring the azure database. Save the file.

Ok, now all your work is done and you can give artisan a go:

D:\home\site>php artisan migrate  
Migrated: 2014_10_12_000000_create_users_table  
Migrated: 2014_10_12_100000_create_password_resets_table  

Wohoo, all done. Now you can use MSSQL whenever you need to!

Let me know what else you're interested in, and I try to give it a go here.