Connecting to Azure SQL Database

Hello all. New Wappler user here. I’m trying to assess the feasibility of using this product to develop apps that are hosted in Azure App Service which utilize Azure SQL Database. I have set up the Target and successfully tested updated deployments. My next step is to try and connect to the SQL Database. This is where I’m getting a very long and not very helpful failure message. I’m using the full server name “#####.database.windows.net” in the Server Address field. Is this correct? Any help would be greatly appreciated.

HI @ACreller.
Welcome to Wappler. :slight_smile:

Have you tried connecting to your Azure SQL Database using something like MSSQL?
If that works, Wappler should work with same credentials.

Thanks for the reply. I can access the database via SSMS. I’m using the same information from that successful login in Wappler. I’ve also set up a connection to the database within the Azure Web App.

I have not used Azure so can’t be of much help here.
As you posted, the failure message shown is not helpful, but if you can post what the message is, probably someone else might be able to decode it?

Hi @ACreller and welcome to Wappler!
I’m sure you will enjoy it.

You should be able to connect to Azure SQL Database without any problems.
Please do share the error you get. It might not be helpful to you, but usually we can see what is wrong and help you.

Guess I need some help on how to get you the error. The Notification window does not allow me to interact with the text and the returned message is way too long for a screenshot to be helpful.

Maybe you can just post a screenshot of what you see exactly :slight_smile:

Hi @ACreller,
I am also facing an issue connecting to sql server via Azure. We’re you able to resolve?

1 Like

Hi All,

I am also trying to connect to an Azure SQL Database, has anyone else managed to get this working. I have tried with all the different types of database connection. I’m pretty sure that the SQL Server should be the correct one though. I have gotten the following error.

SQL Server Connection

@ pholdridge Did you manage to get a solution to this by any chance?

Thanks in advance guys.

I also get this error if I try to test the connection for a second time, which is strange.

I’m not sure if this helps, but on the Azure SQL Database, it gives the following code templates for connection. I replaced my specifics with XXX.

// PHP Data Objects(PDO) Sample Code:
try {
$conn = new PDO(“sqlsrv:server = tcp:XXX.database.windows.net,1433; Database = XXX”, “XXX”, “{your_password_here}”);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
print(“Error connecting to SQL Server.”);
die(print_r($e));
}

// SQL Server Extension Sample Code:
$connectionInfo = array(“UID” => “XXX@XXX”, “pwd” => “{your_password_here}”, “Database” => “XXX”, “LoginTimeout” => 30, “Encrypt” => 1, “TrustServerCertificate” => 0);
$serverName = “tcp:XXX.database.windows.net,1433”;
$conn = sqlsrv_connect($serverName, $connectionInfo);

EDIT:

After some research online I wonder if this is a Mac specific issue, if anyone that is PC based is willing to spend 5 minutes checking the connection, I could PM them a temporary username and password to try and troubleshoot this issue.

Hi @wahlrab,

To make any connection at all - it is first very important to get the ftp connection right to your web server.
As the test message is telling you - the web server url can’t be found …

So make sure you have to good http address and that all the remote upload folder is right.

Once you have the ftp connection right - then you can connect to your database, because the database connection goes through you web server.

The driver not found error means actually that there are no PDO SQL Server drivers installed on your web server, so you should check this if you still got it afterwards.

Hi George,

Thanks for the reply. Just to clarify a few things that I didn’t explain.

I currently have a website and php application that I built using Wappler, which is great by the way, that is being hosted by a third party on an apache web server. I have used Wappler to connect to mySQL databases that are setup on this web server to store user data. In this sense I have the FTP for the remote upload fully up and running without any issues. Now this is where I start to talk about things that I don’t have much knowledge on.

I currently have IOT devices collecting data, which is then piped into an Azure SQL Database. What I was hoping to do is link this Azure SQL Database to the my website also, but as you mentioned, it seems that my web server does not have the correct PDO SQL Server drivers to do this, although perhaps this is not something that can be done even if my hosted web server had the drivers? Essentially I am looking for some advice on a full stack architecture, but I realise that my questions here start to fall outside the realm of the Wappler application. I might create a fresh post looking for some advice in this regard.

It is no problem to ask architectural questions at all here @wahlrab - just make a separate topic with clear explanation what your intend is. That is the great thing about the Wappler community - it is not just about Wappler but also about sharing experiences and advice. There are many full stack developers and gurus here that will be glad to help.

As for your SQL Server connection from the PHP server - yes you need to have the PDO drivers installed.

Thanks for the advice George, I have created a new post and tried to explain the situation as much as possible. Again, I am very impressed with Wappler so fay. :slight_smile: