Closed tao closed 4 months ago
@sanchitmehta please advise.
@kichalla @arroyc Could you please help us with this ?
We currently do not install database drivers in build image and only do in runtime images.
@suwatch @sanchitmehta Could you create a new label Oryx
and tag issues which you see are related to my team.
Could you suggest alternative solutions to run a database migration for a Laravel app hosted on Azure?
Typically I have seen articles talking about running migration from your development machine against the prod database. https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-php-mysql-app
I don't believe that's good practice because it's very likely that I or someone else on the team will forget, and I would rather keep the database credentials on Azure.
@kichalla I am facing the same issue with SQL Server. My "php -m" on the Web App shows "sqlsrv" and "pdo_sqlsrv" as PHP modules, although "php -m" on the Kudu side does not.
As @tao commented, it does not sound like a good practice to leave it to the dev to migrate Production databaseS (in our case, we have several Production resource groups, hence several Production databases to be migrated).
It is only natural to think that the deployment script should be able to execute the migration as part of the CI/CD pipeline. IDK how people are deploying laravel applications without performing "migrate" as part of the process to be honest...
Thanks @tao and @garimpeirodouniverso ...we will look into this and get back to you
¿Any news with this issue?
Hi
If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure: https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request
This way we can better track and assist you on this case
Thanks,
Joaquin Vano Azure App Service
I am trying to deploy a Laravel 6 application to Linux on Azure with Postgres, and using a Kudu script to run
composer install
and set up the app. During the Kudu script I want to runphp artisan migrate
and migrate the new database changes on each new deployment.The Laravel app works perfectly on the Azure WebApp, so this is specifically a Kudu issue.
If you SSH into the server and run the command
php artisan migrate
it works fine, but the Kudu script doesn't seem to run on the same PHP settings so it's seems impossible to get it working.The Web app/SSH reads PHP configs from
Configuration File (php.ini) Path: /usr/local/etc/php
While Kudu seems to read the configs from:
Configuration File (php.ini) Path: /opt/php/7.3.11/ini
When Kudu runs from
opt/php/
it doesn’t have access to the Postgres database driverphp_pdo_pgsql
which is causing our issue. I have also tried a standard WebApp and a Docker image but they both have the same problem.I have also tried installing the Postgres database driver
php-pgsql
manually during the Kudu script in order to activate this but installing packages seems locked down on Kudu. I have tried:The Azure documentation also has articles on setting up custom php ini configs using
.user.ini
files orsettings.ini
files, or even changing PHP_INI_SCAN_DIR but these again seem to work only on the Web App but don’t seem to affect the Kudu environment.I have created these
.user.ini
and settings files like this:After trying this, it does detect the changes but looks in the wrong directory again for these files:
If you look at the PHP ini configs enabled during the Kudu script with
php -m
it shows these:While the WebApp itself has access to all the correct ini settings:
The
docker-php-ext-pdo_pgsql.ini
anddocker-php-ext-pgsql.ini
modules do exist on the server, so I've also tried setting PHP_INI_SCAN_DIR in the app config to/usr/local/etc/php/conf.d/
but that doesn't change the ini settings on the Kudu script either.I have even tried a post deployment script using POST_DEPLOYMENT_ACTION on the app configuration, which runs the script
/home/site/deployments/tools/post-deploy.sh
:That script runs afterwards and scans for additional ini files but still fails with the same errors:
The actual error that occurs each time is:
I have an example Laravel 6 repository available here: tao/kudu-laravel6
Is there something I'm missing in how this works? How could we get access to the Postgres database driver during the Kudu script or if that's not possible how else can I run my database migrations for Laravel?