Jump to content

Easy way to migrate an existing PHP site with MySQL to Azure App Service.


Recommended Posts

Guest vinku85
Posted

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 1.

  • 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:

 

750x137vv2.png.4812d643fbefcdae82f76266dffb0526.png

 

 

 

  • 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.

 

751x211vv2.png.070954b49847245b121d970d7d099574.png

 

 

 

751x389vv2.png.7710a0543493f1d4e0efc1c1bc556c51.png

 

 

 

  • Select "WebSSH" and go to /home/site, run the below command to import the sql dump after replacing Username, Password, Hostname, port (which is 3306 by default), and destination database name:
    mysql -h Hostname -u Username -p --ssl-ca=/home/site/DigiCertGlobalRootCA.crt.pem destination_database_name < dump.sql

 

750x163vv2.png.2b31786d1877e18338f0e431118194de.png

 

 

 

  • 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_CA =>'/home/site/DigiCertGlobalRootCA.crt.pem',

\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false

],

);

 

 

 

 

 

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...