After upgrade to php 8.1 (Linux PHP) , Azure webapp does not seems to have driver for MS SQL. It was OK with php 7.4.
Following this guide (https://learn.microsoft.com/en-us/azure/app-service/deploy-local-git?tabs=cli), steps to build and configure Azure App service was: az appservice plan create -g rg-MyResourceG -n MyPlan --is-linux az webapp create -g rg-MyResource --plan MyPlan --name MyApp --% --runtime "PHP|7.4" --deployment-local-git Change to PHP 8.1 following this guide: https://github.com/Azure/app-service-linux-docs/blob/master/Runtime_Support/php_support.md az webapp config appsettings set --name MyApp --resource-group MyResourceG --settings DEPLOYMENT_BRANCH='main' on my local server: php artisan key:generate --show az webapp config appsettings set --name Glados9L --resource-group rg-blueprism-tst --settings APP_KEY="Output from last command" APP_DEBUG="true" git remote add glados9l https://[email protected]/MyApp.git git push glados9l main ........... remote: Done in 223 sec(s). remote: remote: Removing existing manifest file remote: Creating a manifest file... remote: Manifest file created. remote: Copying .ostype to manifest output directory. remote: remote: Done in 457 sec(s). remote: Running post deployment command(s)... remote: remote: Generating summary of Oryx build remote: Parsing the build logs remote: Found 0 issue(s) remote: remote: Build Summary : remote: =============== remote: Errors (0) remote: Warnings (0) remote: remote: Triggering recycle (preview mode disabled). remote: Deployment successful. deployer = deploymentPath = remote: Deployment Logs : 'https://glados9l.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/ef2b3e8ce9341d66fa5e64826721e09085dbe214/log' To https://myplan.scm.azurewebsites.net/Glados9L.git
root@9dcf7762daa9:/home# php -i | grep sqlsrv
Cannot load Zend OPcache - it was already loaded
root@9dcf7762daa9:/home# odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
root@9dcf7762daa9:/home# php -v
Cannot load Zend OPcache - it was already loaded
PHP 8.1.6 (cli) (built: Aug 17 2022 07:43:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
root@9dcf7762daa9:/home#
It is a known issue that pdo_sqlsrv is missing in PHP 8.1 image and according to this pull request, they are adding this driver soon.
As for now, you can download and enable it manually by following this post
I have the same issue. My app was working perfectly for a few years. After switching the azure webapp from PHP7.4 to PHP8, the connection with the SQL server fail. (PHP7.4 is depreciated soon)
I get this error message on when I connect to the page with my browser.
Error connedmg to SOL Server PDOException Obred ( [message protected] => could not find driver [string Excephorrpnvate]=> [code protected] => 0 [file protected] -> ihome/siteAmwroot/DEV railtypeWrthProcess php [line protected] => 122 [trace Exception pnvate]=> Array ( [0] => Array ( [file] => /home/site/wwwroot/DEVraillypeWith Process php [line] => 122 [function] -> construct [class] => POO [type] => -> [args] => Array ( [0] sglsry server - lcp delachauxrailtechbddserver database windows net,1433, Database = BDDWeldingKrtAPP [1] => weldingKrtApp01 [2] => ****** ) ) ) [previous Exception pnvate]=> [errorInfo] ) 1
Here how I connect to the server with PHP.
try {
$conn = new PDO("sqlsrv:server = tcp:delachauxrailtechbddserver.database.windows.net,1433; Database = BDDWeldingKitAPP", "weldingKitApp01", "******");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
print("Error connecting to SQL Server.");
die(print_r($e));
}
The webapp was created using the Azure console interface. Not with command.
Thank you for your support.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.