Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cwray-tech's avatar

Connecting to Azure SQL Database from Digital Ocean Ubuntu Server

Hey there, I am having some issues with connecting and using an Azure SQL database when coming from my Laravel app on an ubuntu server.

I have gone through the Microsoft docs for connecting to a SQL database from a PHP app and run the connection wizard from Azure to see if my servers could connect, which they can.

I believe I have an issue with the PHP.ini configuration but followed Microsofts docs on that as well. Does anyone have experience with this?

The Digitial ocean server is configured by Laravel Forge.

The Azure database we need to connect to is on Microsoft Azure and set up through their admin area.

I have whitelisted the Azure database server to accept incoming connections from the Digital Ocean Server.

0 likes
10 replies
cwray-tech's avatar

@Sinnbeck I'm unfortunately not getting any error.

When I try to migrate data using a command, the command line is empty and stalls... BUTT I just checked the log file and looking like I'm getting an invalid text representation error...

I think that is the issue. Weird thing is that we are not seeing that issue locally and can run the command just fine. (What it does is take data from the Azure database and insert it into the new PG database.)

[previous exception] [object] (PDOException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type bigint: \"acesdaff\"
Sinnbeck's avatar

@cwray-tech so the azure database has data? Can you select data normally?

cwray-tech's avatar

@Sinnbeck Also, yeah it works just like a normal SQL Server. I did follow that guide. Thank you for your help!

cwray-tech's avatar

@Sinnbeck Yes, so we can run the command just fine running locally and yes the database has all of the data from the clients old application. We're only doing select commands and some transformations on our end.

Sinnbeck's avatar

@cwray-tech so try a very simple select in a test view

\DB::connection('sqlsrv')->table('xx')->limit(10)->get();
1 like
cwray-tech's avatar

@Sinnbeck Will do. I'm going to be away for a bit but will try as soon as I'm able. Appreciate those questions and advice greatly! Why I love posting things here. Clears the mind so much haha.

Sinnbeck's avatar

@cwray-tech happy to help. Best way I find to solve issues like this is to break down the issue to the simplest parts

1 like
cwray-tech's avatar

@Sinnbeck yes for sure. Guess what? it was working fine the entire time! I just was not being patient, and in the production environment, the console logs were not being displayed. When I switched the environment to dev and debug to test and run the command everything went smoothly.

Thanks a bunch for your help. Just having someone to question helped as I was going to do what you mentioned with dev enabled, and decided to try again in that environment. Thanks again!

Sinnbeck's avatar

@cwray-tech awesome to hear. And happy to help. Please mark best answer to set the thread as solved

Please or to participate in this conversation.