/ azure

Scaling WordPress on Azure with PaaS - Part 2

Now that we have the foundational elements in place, let's create some excellent WordPress!

Create WordPress Web App and Configure

From the browser window, we’re going to now deploy a Web App for Containers into our App Service Plan by entering a special URL. That URL is:

Enter that into the browser tab you are using for the Azure portal (you don’t need a new tab unless you want to) and press Enter. This will take you to the deployment page of a template provided by Microsoft for deploying a Linux Container that supports the setup we’re looking for.
After a few moments, the Azure portal will reload with the template ready for parameters so it can deploy our WordPress container.
Fill in the parameters as described below.

  1. App Name – this is globally unique to Azure. Note that it is the full web address of your new WordPress installation. I suggest you copy this to Notepad for reference and it will take the form: http://.azurewebsites.net
  2. Subscription will auto fill in from your trial subscription.
  3. In Resource Group, select Use Existing and select the Resource Group you created earlier.
  4. For App Service plan/Location, click it and select the App Service plan you created earlier (also in East US).
  5. In the database blade, complete the form as described below
    a. Database server – Use Existing and select the MySQL DB you created earlier
    b. Enter the password for the MySQL Server Admin that you copied into Notepad earlier
    c. In Database, select Create New and give it a friendly name – I used ‘wordpress’ – you may as well. Note this down in Notepad as you will need it shortly.
  6. Click OK on the Database server blade
  7. Select OFF for Application Insights
  8. Click OK on the WordPress on Linux creation blade.


Open a new tab and type in the address of the website you just created. Note that the site creation in the portal will complete almost instantly, however, navigating to your new site can take several minutes. This is because the container is being downloaded and built. Please be patient until you see the following welcome screen.


Press Continue to begin completing the setup wizard. This will require you to provide the details of the MySQL database server and database you created during the deployment above.

  1. Database name – this is the name of the database you created above during the deployment of the Web App template for WordPress.
  2. Username – this is the username from the deployment of the MySQL server (the MySQL server admin) in the format of @
  3. Password – this is the administrator password from the deployment of the MySQL server.
  4. Database Host – this is the complete server name of the MySQL server you copied down when creating the MySQL server.
  5. Table Prefix – this defaults to wp_ - you may leave it as is.
  6. Click Submit


If you entered these fields correctly, you will see the following screen.

This screen confirms you were able to connect to the MySQL database server AND it can see the database correctly. Click Run the installation.
The next screen will have you create the first user (administrator) of the MySQL environment. Fill it out as below.

  1. Site Title – this can be anything you like. It is the Name of your WordPress site.
  2. Username – anything but ADMIN or ROOT will work here
  3. Password – anything as long as it is strong
  4. A valid email – it isn’t needed but it does check to make sure it is at least in the correct format.
  5. Search Engine Visibility – just leave unchecked for now.
  6. Click Install WordPress.


Installation takes about 90 seconds. During this time, the MySQL database server is being populated with tables and initial data and configuration. You will then be prompted to log in. Do so and you will see the following Admin screen.

Within the WordPress Admin portal, click Plugins and then click Add New.

In the search box, type the word Redis as below.

Choose the middle one: Redis Object Cache by clicking Install Now. After a moment, the Install Now button will change to say “Activate.” Click Activate.

Back in the Plugins page, you will see that it is listed and activated.

Click Settings under Redis Object Cache.
Next, we note that while the plugin is activated, it must be configured. By default, the plugin looks for a Redis Cache on the server it is running. Click the Diagnostic Data button to see that we are NOT connected to Redis and we are disabled.

Note: There is a difference between the Redis module being Activated and the Redis module being Enabled. Currently, we are Activated but Disabled. We need to configure the module before we attempt to Enable it on this screen.
On the Azure Portal tab, open the Redis instance you created earlier from the Resource Group pane.

Note we see that we have a Host name and Non-SSL port 6379 is enabled. Make sure that the host name matches what you have copied down into Notepad. Next, we need to get the password. Click Show access keys… in the center of the Redis Cache blade.

Click the Copy button next to the Primary key (top box). This will copy the password (ending in ‘=’) to the clipboard. Paste it into your Notepad.
Next, close the Redis Cache blade and open up the Web App blade for our WordPress installation. In this illustration, it is the bottom item, called “dermarwplab” with a globe as its icon.

Once you have opened it up, we are going to edit the WordPress configuration file on the running container. To do so requires SSH. Fortunately, Azure App Services provides one for us. Click the SSH tab found on the Web App blade you just opened.

Click the Go button. This will open a new tab and you will be presented with a screen like this.

You are now looking at an SSH shell window inside the running App Services Container. From here, we can modify the running WordPress config file to point to our Redis Cache using the details gathered above.
Type the following command and press enter:
vi /home/site/wwwroot/wp-config.php

Depending on your screen resolution, you will see a somewhat smooshed window. That’s okay!

Note that the last line of text which ends in 1%  that is the last line of the console window, despite there being more screen space below it. Press the DOWN arrow until you get to the line that says: “define(‘DB_COLLATE’, ‘’);^M followed by another ^M. Press the RIGHT arrow until it is to the RIGHT of the M as below.

Press the ‘i’ button (no quotes). This puts you into VI’s “insert” mode.” You will see on the last line of your screen an I, followed by /home/site/wwwroot…
Press ENTER to insert a new line between the ^M and the line /**#@+^M
Enter the following text:
define(‘WP_REDIS_HOST’, ‘’);
define(‘WP_REDIS_PASSWORD’, ‘’);
(Thankfully right click/paste works in this window!!!)
The text should look similar to the below.


Once you have those two lines typed in, press ESC and then the following key sequence:
This stands for (:)command mode,(w) write the changes to disk, (q) quit VI.
Once you press enter (don’t type it 😊) you will be returned to the console window. You may now close this browser tab.


This process completes almost instantly. You’re now going to refresh the tab that we left earlier which was on the Redis Plugin settings page within the WordPress Admin site. When you refresh that tab, it will take just a moment to reload, however, you should see a change.
Note that the Host field now has your Redis server listed. Click the Enable Object Cache button and then click Show Diagnostic.

You should see status: Connected
Finally, let’s warm up the cache and get some data going into it. Click the Posts/All posts button in the WordPress Admin site and EDIT the initial post with anything you want.

When you are done, click the Update button which is found on the far right hand side.
Next, open a new tab in your browser and navigate to your site in the form of: http://.azurewebsites.net
You will see a HUGE image – that’s just from the template. Scroll down and you should see your updated text.


Now, back in the Azure Portal tab, close the Web App blade and open up the Redis Cache blade from the Resource Group. In the below picture, it is the top item whose icon looks like a database cylinder with a lightning bolt, but to be sure, look to the right and see the type which says Redis Cache.

When you open the site, click the button for Redis Metrics (see red arrow in the below image).

That screen will open, and you should see some basic activity similar to the below.