AzureRM WordPress migrate to Docker MySQL complete story

Wanted to document my journey to get this blog up and going in Azure. This was a experiment as much as anything. Though the result was not too shabby.

First we start by creating a new Azure WordPress Web App. Press New and search for WordPress

AzureRMNew

Choose the WordPress web app and accept the terms.

WordpressWebApp

Fill out the details needed. Create a resource group to hold your application.AzureRMWPConfig

Also create a service plan and choose the resources you want to use.

AzureRMWPAppServicePlan

Then choose the details for the MySQL database. I am using the default name, though I highly recommend to change this to something else. It will make the database retrieval easier later. Choose the free Mercury tier.

AzureRMWPMySQL

Finally accept the legal terms.

Wait for the application to be created, then navigate to Resource Groups.
AzureRMrg

Find the resource group that was created during the WordPress install. Then find the MySQL database resource.

AzureRMmySQL

Enter and choose Settings and then properties.

AzureRMmySQLSettings

Now you will see the details needed to later be able to connect to the DB and back it up.

AzureRMmySQLCon

Write these details down and save them for later. Now lets create the MySQL Docker container we want to host in our Azure subscription.

AzureRMmySQLDocker

Fill out the details needed, these are also needed later for the database restore operation.

AzureRMmySQLDsettings

Put the server in the same resource group what was created for the WordPress web app.

AzureRMDsettings2

Create the container and after it is finished find the VM and enter Settings (Note from now on it will be called LerunMySQL, not MySQL as we started with).

AzureRMDPIP

Press the public IP to go directly to the configuration settings.

AzureRMDPIPConfig

In the configuration pane set a DNS name for you database instance, we will use this later.

AzureRMDPIPConfig2

The last thing we need to configure is to allow the port MySQL is shared on through too the container/ VM. Go back to the VM pane, and click Network interfaces.

AzureRMmySQLDnet

Here click Network Security Group.

AzureRMmySQLDnetsec

Enter Inbound security rules.

AzureRMmySQLDnetFW1

Here allow MySQL on port 3306 through.

AzureRMmySQLDnetFW2

Before we move on remember to stop the web app.

AzureRMWPSetting

Now we are ready to retrieve the database from the hoster. To do this download and install MySQL Workbench.

Before we start the program, we need to fix something to allow us to do the export. Follow the details explained below, or go here.

MySQLWBfix

When this is done start it up, as we need to connect to where our database is hosted. Create a new server connection, and enter the details from earlier.

AzureRMmySQLWBcon

When done, press Test Connection.

AzureRMmySQLWBcon2

Save the password, as it will be easier to connect after the test.

After the test passes, go back to the main menu and connect to the database.

AzureRMmySQLWBcon3

Now lets back up our WordPress database.

AzureRMmySQLWBbackup

Go to the export pane, and choose where to store the file. Also remember to chose the thing you want to export. As I choose the default name, I will get a random generated database name. If you choose a better name, this is what you now should see in the workbench.

AzureRMmySQLWBbackup2

Export it, and check that there are no errors.

AzureRMmySQLDexportfin

Now we need to connect to the MySQL Docker container/ VM we created earlier. Use the same logic as before, and get the “MySQL root password” entered during the creation of the VM. You will also need the DNS name entered previously for the public IP. Create a new connection for this in the workbench.

AzureRMmySQLDWBcon

As before test the connection. Then connect to the instance.

First we need to create the database to be able to import the backup. Do this by using the create database databasename statement. The name of the database must be the same you backed up from the other instance.

AzureRMmySQLDdb

Now we can import the file into our newly created database. Remember to choose the database name you just created from the Default Target Schema drop down.

AzureRMmySQLDimport

The last order of business is to create a user we will use to access the database from WordPress.

AzureRMmySQLDdbuser

Give it a name and choose Authentication Type = Standard.

AzureRMmySQLDdbuser2

Next give it access to the database.

AzureRMmySQLDdbuser3

That is the end of the migration.

Now we need to change the connection string in WordPress. First we need the FTP link and the username and password. This is found on the web app.

AzureRMWPSetting

Copy the FTP host name, and choose Get Publish Profile. This will download a file, and inside you will find the username and password for the FTP host.

Next get FileZilla and create a new connection to the FTP host.AzureRMFTP

Find the wp-config.php file and download it. Open the file in a text editor like Notepad++.
Change the database connection details to match what we have created previously in this blog. Remember to use the exact same upper/lower case letters as used previously.

AzureRMWPfileconfig

Save the file and upload it to the FTP host in the same location. Make sure you overwrite the existing one.

Thats it, you should now have a WordPress site in Azure Resource Manager.

Happy tinkering!

Note:
From a security perspective it is good practice to encrypt the connection between WordPress and MySQL. This is a bit more intricate and involves generating certificates with OpenSSL and opening up the docker container witch houses the MySQL application to add the appropriate certificate files there.

I have made another post talking about how to add some security to the MySQL install here.

One thought on “AzureRM WordPress migrate to Docker MySQL complete story

  1. Pingback: Website Update 01-13-16 – The Imaginative Universal

Leave a Reply

Your email address will not be published. Required fields are marked *