In this blog, we will cover the easy way to migrate an existing PHP site with MySQL to Azure App Service.
- This setup will create a VNET and MySQL database where the MySQL access will be locked down and not exposed to the public internet, which is compliant with recommended best practices for security.
- During the deployment to install any application dependencies like composer packages add an app setting,
SCM_DO_BUILD_DURING_DEPLOYMENT, and setting it to
- To migrate the MySQL database, we can use the Azure App Service Kudu console.
- The easiest way to get to the Kudu console would be to go directly to http://yoursitename.scm.azurewebsites.net/newui (replace "yoursitename" with your actual Web App name) through the browser. You can also launch the Kudu console from the Azure portal:
- Select "File Manager" and drag or upload the "dump.sql" file to the /home/site directory and the certificate needed to communicate over SSL, which you can get from the Azure Portal.
- This should populate all your data from "dump.sql" into the Azure MySQL - Flexible MySQL database over a secure connection.
- For a Drupal application secure database connection, use the below code:
$databases['default']['default'] = array (
'database' => 'quickstartdb',
'username' => ‘myadmin@mydemoserver,
'password' => ‘yourpassword',
'prefix' => '',
'host' => 'mydemoserver.mysql.database.azure.com ',
'port' => '3306',
'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
'driver' => 'mysql',
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
'pdo' => [
\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false