Migrating a WordPress DB from MySQL in-app to MySQL on Azure


Let me tell you a secret. I have been running my blog on the MySQL in App instance provided with each Azure App Service web application for the last few months. Yes, I know that is not a best practice. However, I didn’t want to have to do the ClearDb or host a Linux VM options and I knew Azure would have a MySQL service someday. Today, 5/10/2017, Microsoft announced a new service available in-preview on Azure. They are offering a Database-as-a-Service (DBaaS) for MySQL and PostgresSQL in addition to the SQL Server service. Get excited! You can read all about the service, pricing and documentation here. This post is about migrating a WordPress db from the MySQL in App instance to this new service. You can read more about the in-app instance here, but the goal of the in-app feature was only for development. Hence, the need to migrate, asap.


Software Tools

  1. Any web browser
  2. Visual Studio Code
  3. MySQL Workbench
  4. Any ftp client
  5. Optionally, phpMyAdmin


  1. Assumptions and Preparations
  2. Create an Azure Database for MySQL
  3. Export and Importing the Existing Database
  4. Deploy WordPress to Staging Environment
  5. Swap Production and Staging Environments

Let’s begin.

Assumptions and Preparations

I am assuming a couple of things about the audience for this post. First, that you have a valid Azure subscription and know what PaaS means. Second, you are familiar with administering a WordPress blog running in an Azure App Service using the Standard pricing tier.

This last bit of preparation is configuration. Let me start by saying, configuration management is difficult even for small apps. I originally deployed this app with the idea of only having a staging site and a production site. However, this was not feasible as there was some weird issues with the MySQL in-app between the 2. As a result, I just use my development environment as the testing ground before production. Additionally, I don’t install any plugins in dev they are all installed in prod, backed up and copied down to dev. Anyway, I originally configured the wp-config.php file to dynamically read the server environment variables so that I wouldn’t have to reconfigure each environment. Because that is a pain. Below is the code I used for this. Once I got this working it was nice not to have to remember configuration settings for each environment. You are welcome to use this. If you only have one deployment I don’t think you will have to but you can. Here is a gist for you.

custom wordpress config file

Create an Azure Database for MySQL

This step is simple enough. Just search for the service and follow the prompts. However, once the database completes deploying there are 2 things required.

  1. Ensure the force SSL is disabled.

    azure enable ssl settings

  1. Add a firewall rule to allow all IP’s. This was s setting I discovered by creating a Web App + MySQL test application in Azure from the Marketplace.

    azure mysql db firewall settings

Exporting the Existing Database

There are 2 options, maybe more and not even one is better than the next. I will discuss the options I tried and note the one that I went with because it’s easier.

Option 1: Using phpMyAdmin

This is the less preferred method because I am not really a fan of phpMyAdmin but it is the method provided in the WordPress codex here.

phpmyadmin export tables

Exporting this way will provide you with a SQL file that you can then run against your new database.

NOTE: This script shows creating the database. Just manually create your database in your new SQL Database for MySQL via MySQL workbench. Also, don’t use localdb. That is for demo purposes.

phpmyadmin export sql file

Option 2: Using the Azure Portal

This is the preferred method and extremely simple. It’s like the Azure devs knew that the in-app instance would need an export function. It’s as simple as just entering the security credentials to the MySQL Server and clicking a button. So, here are some pictures for reference.

Note: I initially had an issue with connecting to the SQL database for MySQL doing this. However, I disabled the force SSL and added the firewall rule and it worked seamlessly.

azure mysql in app export

azure mysql in app export form

azure mysql in app export screen

Deploy WordPress in Staging Environment

This next step you’ll want to test out your work to see if all went well. Luckily, Azure App Service has an excellent feature for that; deployment slots. It’s easy to create a deployment slot. In the production app blade select the section for deployment slots and add a slot. I cloned the source configuration so that things would be identical to test out.

azure create web app deployment slot form

azure web apps deployment slot screen

In the staging deployment turn off the MySQL in App feature.

disable azure web app mysql in app

Also in staging, delete the old application settings specific to the MySQL in App instance and add your connection string. The format of the connection string is Database={dbName};Data Source={dbHost};User Id={userName};Password={password}

delete azure web application settings

This next step requires and FTP client. I use FileZilla but whatever your preference is will work fine. Make sure to configure the ftp client to connect to production and staging. Connect to production and download the production WordPress application code.

filezilla file download

Now, connect to staging and upload the application code.

filezilla ftp file upload

In the wp-config.php file, ensure the database connection string key matches the key from the application settings. Reupload the wp-config.php file via ftp client, if necessary.

wordpress config settings file

Test the staging URL and make sure everything works. Click links, read posts, etc. If all goes well, move to the last step.

Swap Production and Staging Environments

Swap staging and production. This is easy enough, just click the swap button via the staging or production website overview blade. Below is a sample of what the swap button looks like.

azure web app deployment slot swap


Migrating a database is easy in MySQL and I really enjoyed using the MySQL Workbench tool. Additionally, now the site is scalable. Where before it wasn’t because each MySQL in-app instance was unique to the website instance. Meaning, if the site scaled to 100 instances there would also be 100 MySQL in app instances. This alleviates this issue. However, I doubt many users will need to do this but it is documented here. Enjoy.


Blender 3D: An Open-Source C++ Development Project



During the spring semester of 2015, I completed a course on C++ and I have been itching to find a project where I could put those skills to use. Furthermore, I have attained post-baccalaureate certificates in Computer Aided Design (CAD) and Building Information Modeling (BIM) which involve using complex computer programs to create 2D technical drawings and 3D models. These programs are enigmatic to the end-user but it is spectacular the things people create using them. However, I have only used my design and computer graphics skills as a hobby. But that is about to change. I am going to start contributing to the development of Blender. An open-source 3D modeling, animation suite and gaming engine. This is extremely exciting for me as I have always enjoyed using these programs and now I will be involved in creating them.

In this post, I am going to walk through the process of setting up the blender development environment on Windows 10 and Visual Studio 2017 (VS) so that I can code and debug natively in VS. In doing this, I will provide a brief overview of the CMake tooling, discuss the new CMake support in Visual Studio 2017, detail the process per the development documents at wiki.blender.org as it relates to the native process and identify a starting point for developing on Blender. Let’s begin.


Be aware that there are multiple entry points into building the source code successfully with CMake which I found out the hard way. Ultimately, I want a visual studio solution file to work with because that is where I am most comfortable. Let me itemize the different attempts so you don’t have to. First, I installed CMake separate to VS2017 and used the CMake GUI to create the visual studio solution. Second, I got VS to build the source code into a temp folder. Lastly, I followed the blender.org instructions and used the command-line and provided batch file. Each attempt provided the same output of a directory with a solution file and many project files. I did not know this at the time but this output folder is what I would end up building. I finally discovered the below high-level overview.

High-level Overview

  1. Install Visual Studio 2017
  2. Install SVN
  3. Clone Source Code in VS using Git
  4. Generate solution files using CMake (VS completes this step while generating cache step but it’s good to know)
  5. Compile Blender

Installing Visual Studio 2017

The free Community edition includes everything you need to begin developing in any area. So, go ahead and grab the free version here. The new installation experience in Visual Studio is awesome. The VS team has made the installation process simpler and easy to maintain by separating the content into workloads. However, even though they have done this I still install almost everything or everything that I hope to use. You don’t have to do this just make sure to install the Desktop development with C++ workload. It is important to note that Git and CMake are now first-class citizens in VS. This means that installing VS includes Git and installing the C++ tooling includes CMake and they are not an extra install process.

Note that the blender.org documentation states to install CMake separate to VS. However, this is unnecessary since VS now includes CMake.

You may be wondering what is CMake and why is it so important to this project. I’ll explain that next.

What is CMake?

Honestly, I had never heard of CMake before I started working on this project. However, stated directly on cmake.org, it is a suite of open-source cross-platform build, test and package tools. Awesome. The latest support for CMake in Visual Studio 2017 makes quite a lot of sense because Microsoft has invested heavily in open-source and cross-platform development tooling in recent years. This is great for any dedicated Visual Studio developer because expanding the toolset for a developer is like dipping strawberries in sugar. The strawberries are already sweet but dipping them in sugar is even better. Anyway, the documents at blender.org state that the source code compiles on a Mac using xCode, Windows using Visual Studio or several of the Linux distro’s and IDE’s. Which goes to show that CMake works. As stated before I am using Visual Studio 2017 on Windows 10 and there is a great blog post on the Visual C++ Blog that details the capabilities of CMake in VS2017 as a result, I am not going to go into too much detail. Let’s clone the repository.

Clone the Blender Git Repository

  1. Create a top-level development folder to work from. I am using blenderdev and the blender.org docs use blender-git.

blender dev top-level folder

  1. In VS navigate to Team tab on the menu bar and select Manage Connection.

team connections button in visual studio team explorer

  1. In the local repository section, select clone and copy the git://git.blender.org/blender.git into the available textbox.
    1. Make sure to change the location of the blender folder to the folder you specified in step 1.
    2. It’s on by default but ensure the Recursively Clone Submodules checkbox is checked.

    git clone in visual studio team explorer

  2. Select the clone button. Cloning might take a bit; the repository is quite large and VS/CMake needs to build a cache of the files.
    1. Additionally, make sure to change the configuration to match your OS’s bit version. For example, x86 or x64. Doing this will use the correct compiler when building the files.

cmake build settings

  1. After VS has completed building the files and indexing the cache you should see the output:

visual studio cmake cache output result

  1. Note the last line, build files have been written to C:\ …. This is not what we want. We want to put them in the folder we created in step 1. We will configure CMake in the next step.

Configuring CMake in VS2017

We want to build the files in our working folder. Configuring CMake will do this for us.

  1. Right-click the CMakeLists.txt and select Change CMake Settings from the flyout

edit cmake settings fly-out

  1. This will create a file titled CMakeSettings.json. Change the buildRoot node of each configuration in the file to “${projectDir}\\..\\blender_build_${name}”. This will build the files under your top-level folder in a folder titled blender_build_x64-Debug.

visual studio cmake file editing

  1. Navigate to the Team Explorer tab in VS and right-click the CMakeSettings.json file and choose to ignore this local item. Note: this may get updated in the remote repository .gitignore and you might not need to do this.
  2. Let CMake finish generating the cache and close Visual Studio. We will install SVN and use the generated solution files in the blender_build_x64-Debug folder to work with the source code.

Installing and Cloning the SVN Source Libraries

Install TortoiseSVN and make sure that you put the SVN location in your path; select yes when the installer asks if you want to include it. Open a command prompt in your top-level working folder and checkout the 32 or 64-bit libraries from SVN.

svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows_vc14 lib/windows_vc14

Compile the Source Code in Visual Studio 2017

  1. Open the solution file located in the blender_build_x64 folder.
  2. Select the blender project and make it the startup project
  3. Build the INSTALL project
  4. Go get a coffee or a sandwich because it takes a while to build.


That completes the native setup of Blender in Visual Studio 2017. After the build of the install project from the solution explorer window there will be a folder in your working folder titled install which will contain the executable to run and debug/test your changes. The new CMake support in Visual Studio removes the unnecessary command-line scripts per the original documents. By installing, Visual Studio 2017 you get CMake and Git integration right out of the box. Additionally, Visual Studio’s CMake support provides a simple configuration mechanism. Unfortunately, the blender 32 and 64-bit libraries are in SVN as a result, you’ll have to install an SVN client. Following this development process will alleviate the need to install Visual Studio, CMake, Git and SVN resulting in just installing Visual Studio and SVN. It’s much simpler this way. If you have an questions feel free to contact me via any of my social media profiles; Twitter, Facebook , LinkedIn and Google.