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
- [new branch] main -> main
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#
3
Answers
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.
Here how I connect to the server with PHP.
The webapp was created using the Azure console interface. Not with command.
Thank you for your support.
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
The same thing happened to me the solution: