Two of the most difficult aspects of running a modern website is managing the hosting environment and the backing database. Microsoft Azure offers two different products that can easily run a complex website. By using Azure Database for MySQL and Azure Web Apps, creating and running a WordPress site becomes easier.
In this article, we will run through all the steps necessary to create a simple WordPress site, using Azure Web Apps and Azure Database for MySQL.
There are many ways to host a site. Traditionally, this would be done via a LAMP stack (Linux, Apache, MySQL, and PHP). But why not use a virtual machine with that pre-installed set of software instead of Web Apps and managed MySQL?
With a traditional LAMP stack, there is the typical server administration that is necessary for performance and security. Therefore, you are not just spending time managing your site, you also need to keep the entire Linux operating system up to date, functioning well, and staying secure.
If we offload these tasks to Azure Web Apps and the Azure managed MySQL product, then we simplify the role of an administrator. This allows a website owner to focus on the site instead of all the hosting tasks.
Examples of using Web Apps, are to host a Ghost blog. In this article, we will use these products to create a solid and robust backend for the popular content management system (CMS) WordPress.
Azure Database for MySQL
Managing and optimizing databases is a difficult task. Oftentimes a website owner will need to spend much of their time making sure that the backend database is functioning and readily available.
The good news is. Azure has a managed MySQL service that simplifies these tasks. Using the following steps, we are going to provision a managed MySQL instance, create a MySQL database, and configure the instance for use with WordPress.
Provisioning the Azure Database for MySQL Resource
- Navigate to the Azure Database for MySQL servers section within the Azure Portal and click on Create Azure Database for MySQL server.

2. A form comes after to input the necessary information to provision the instance. Use the following values.
- Resource Group: The chosen resource group will contain both the MySQL database and the Web App.
- Server Name: Name the MySQL instance an appropriate name, which should reflect the environment and the instances purpose.
- Location: The geographic location will help performance if located near where the majority of your websites traffic is originating from.
- Version: In this article, we choose
8.0
, as this is the latest version of MySQL available.

3. Next we will choose the Compute + storage size, which in this article, we are choosing the Basic tier with a single core.

If you want to create Read Replica’s (useful for scaling the reads, and load, across several machines), then choose a size from the General Purpose and Memory Optimized options. These are more expensive but offer more options and performance.
4. Next, define an administrative username (which acts as the root user of MySQL) and an appropriately complex password.

5. Tagging is useful for adding additional metadata to an Azure resource, but not necessary in this example.

6. Finally click on Create to start the process of provisioning the managed MySQL instance.

Once complete, you’re one step closer to your Azure WordPress blog!
Configuring the Azure MySQL Instance
There are important steps to ensure that Azure MySQL instance can communicate with the Web App. Following the steps also allow the creation of the necessary wordpress
database that will be used to house our WordPress data.
Allowing the Necessary Traffic Through the Firewall
- Once the MySQL instance is provisioned, select the instance from the resources list, and navigate to the Connection security section. Once there, click on Add current client IP address.
We are making sure to add our client IP address to allow a third-party MySQL client to connect and create the necessary database. If you are doing this from a different client location, make sure to add that IP instead.

2. Next, we are going to Allow access to Azure Services, this will allow the Web App to communicate with this managed MySQL instance.

Connect to the Managed MySQL Instance and Create the WordPress Database
- Navigate to the Connection strings section as we will need to use the Server and Uid values to connect to our database.

2. In this article, we are going to connect via HeidiSQL, a Windows application for managing MySQL databases, to create the WordPress database. As you can see in the example below, we have entered the IP from the prior Server value and the User as the Uid value. The password used is the same as we originally created when provisioning the instance.

3. Next, navigate to the Advanced section and check, Use SSL, leaving all other values their default.

4. If the client side IP is correct, that was allowed through the firewall, and all other values are accurate, then the next pane should show the default databases that are created with a new MySQL server.

5. Right-click on the server, Unnamed in this example, and choose to Create new → Database.

6. Enter the name wordpress and choose the Collation of utf8mb4_unicode_ci, which is the preferred default for WordPress databases.

7. If the operation was successful, you will see a new wordpress database shown in the list.

If using a command line MySQL client, the code below is all that is necessary to create the same database.
CREATE DATABASE wordpress;
Azure Web App
Microsoft Azure Web App’s offer an application experience that greatly decreases the management required of a traditional hosting environment. For this example, we are going to use the container (Docker) based approach to our WordPress hosting environment.
Provisioning the WordPress Web App
- Navigate to the Azure Web App’s section and click on Create Web App. Next, we will fill in the necessary details to provision our instance.
- Resource Group: Use the same resource group that the Managed MySQL instance was previously stored in.
- Name: Use a descriptive name that easily identifies your web application.
- Publish: Docker Container
- Region: Choose the same region that the Managed MySQL instance was provisioned in to make sure that geographical distance does not hinder performance.

2. Next, we will choose the appropriate App Service Plan Sku. In this article, we are going to use the S1 Production instance.

3. After clicking Next: Docker, we will choose the following WordPress docker container to use as the basis for our web app.
- Image Source: Docker Hub
- Access Type: Public
- Image and tag:
wordpress

4. Due to the specific combination of choices made, Application Insights are not available for use in this Web App, therefore we can move on to Tags.

5. As before, with the Managed MySQL instance, we are opting not to tag these resources.

6. Finally, click on Create to provision the Web App.

You should now have a web app up and running. This web app will be your home base for your Azure WordPress blog.
Azure Web App Configuration
Now that the MySQL database is setup, as is the Web App, we can configure the two resources to talk to each other and finally install WordPress.
There are a few environmental configurations that work together with the WordPress container image to allow us to define what is necessary to connect the container to the MySQL database.
WORDPRESS_DB_HOST
WORDPRESS_DB_USER
WORDPRESS_DB_PASSWORD
WORDPRESS_CONFIG_EXTRA
–define( 'MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL );
The reason that we are adding the additional configuration is to tell WordPress that we are using an SSL connection to connect to the database.
- Navigate to the newly provisioned Web App and the Settings → Configuration section.
2. We are going to add in the application settings as defined above, and as you can see below.
We are purposely not showing the
WORDPRESS_DB_PASSWORD
environmental variable, but this would also need to be entered.



3. You should see the following Application settings defined once all values have been entered.

4. After you click Save, the Web App will restart and use those settings when re-deploying the WordPress container image. Now onto actually installing WordPress in Azure.
Installing WordPress in Azure
The final steps will demonstrate that WordPress can actually function and work with the Azure Managed MySQL instance.
- Navigate to the public URL of your Web App.
2. On the first visit, if everything is functioning, you should be presented with the standard WordPress installation screen.

3. Enter the typical installation information and click on Install.

4. If the installation succeeded, you will see a Success page.

5. Finally, navigate to the public URL and the browser should now show the default theme and hello world placeholder text.

Conclusion
The creation of a Managed MySQL instance and Web App is not that taxing. The abilities and ease of administration make this an extremely compelling combination. With MySQL instance’s ability to easily add Read Replica replication instances (with the correct instance type), scalability becomes easier than ever to manage. This will work for many different CMS applications that can use MySQL and a standard web server Docker container!