• I would suggest you to please check the connection code of your Laravel application running on the Digital Ocean ubuntu VM and ensure that it is as below with regards to connecting with Azure SQL Database: -
DB_CONNECTION=<connection name of the sql db>
DB_HOST=<ip address of the SQL Server>
DB_PORT=<port number for the SQL DB>
DB_DATABASE=mydb
DB_USERNAME=user
DB_PASSWORD=secret
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'mydb'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
Change the ‘mysql’ connection parameters with that of the Azure SQL database connection and try to connect once again. Would suggest you to please check the below community thread for more information on configuring the Laravel server for that purpose: -
How to connect db of a Laravel 7.12 project on a remote ubuntu server without use artisan
• In the ‘.env’ file, do ensure to configure the following lines in it with proper values: -
APP_URL=http://laravel.example.com DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laraveldb DB_USERNAME=laravel DB_PASSWORD=password ’
And the ‘.conf’ file as below: -
<VirtualHost *:80> ServerAdmin admin@example.com ServerName laravel.example.com DocumentRoot /var/www/html/laravel/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/html/laravel> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Once the above are configured successfully, ensure that the outbound network connections from the ubuntu server on which the Laravel app is configured is allowed for the SQL Database port and the respective incoming network connection is allowed on the SQL Server as well. You will need to make these changes on the NSGs relating to the VM and in the ‘Networking’ section on Azure SQL Server wherein you can configure the VM’s IP address from a virtual network to be allowed in it.
For more information, kindly refer to the below link: -
https://snapshooter.com/learn/guides/how-to-install-laravel-ubuntu