February 26, 2018

Scaling WordPress on Azure with PaaS - Part 1

WordPress powers more than 28% of the Internet and it’s immensely popular with our customers too. Similarly, Drupal is another widely used PHP CMS, especially in PS and EDU.

There are a variety of well-considered patterns for deploying WordPress in Azure. This workshop will focus on the ideal architecture for a WordPress app, including:

• Running the PHP app on Azure App Services for Containers. This service provides support for running Docker Containers within Azure App Services. Docker Containers are a fundamental design choice for many products and solutions on the internet and Microsoft makes extensive use of them within our systems. A full understanding of Docker Containers is not required for this lab; however, it would be good to know some basics. A good starting point for study is http://www.docker.com.
• Using Azure’s MySQL-as-a-Service for the database. This service is a full PaaS solution offering of MySQL within Azure.
• Integrating Azure Redis Cache for reducing the load on the database. This service provides an in-memory caching mechanism for improving response times when database servers become loaded with lots of requests as can happen with a robust platform like WordPress.
• Adding Azure CDN to offload the web server traffic to endpoints around the world so visitors experience much faster load times as the CDN caches pages and other web material closer to the user.
At the end of this lab, the student will have familiarity with this deployment pattern and, optionally, be able to explore scaling options for increasing load when your site becomes world famous!

Create Foundational Resources
Our design calls for the following components to be created and configured:

  1. An Azure Database for MySQL
  2. A CDN Profile and Endpoint
  3. An App Service Plan in Linux mode
  4. An App Service for Containers web application


From the Azure Portal, open Resource Groups and then click Add:

From the New Resource Group blade, enter the information below:

  1. Provide a Name for your Resource Group. I chose “WPLab.”
  2. The Subscription will be filled in for you (provided by the lab trial account)
  3. Select East US as the location of the Resource Group.

Once the Resource Group is created, open it to a blank Resource Group blade:

Click the Add button.
In the search box, type: “MySQL” and Select Azure Database for MySQL

Click Create

Fill in the appropriate values as shown:

  1. Server name. This must be globally unique to Azure.
  2. Subscription will be automatically filled in.
  3. Under Resource Group, use the existing Resource Group you just created.
  4. Server admin login name. This must not be ROOT or ADMIN. I chose dermarwplab, choose something similar.
  5. Enter a strong password of at least 12 characters (at least one upper, lower, punctuation) and confirm it.
  6. Select East US as the location of choice.
  7. Select Version 5.7.
  8. For pricing Tier, select Basic.
  9. Press OK on the Pricing Tier blade and then OK on the create blade.

Be sure to note the server name and password as it will be needed later. I put these in Notepad for easier copy/paste. The server name will take the form of: .mysql.database.azure.com.
Return to the Resource Group screen while that resource creates and click Add again.


In the Search box, type the word Redis and select Redis Cache.

Make sure the item you selected matches the item above (Redis Cache by Microsoft) and click Create.
Fill in the appropriate values as below for the Redis Cache server.

  1. For DNS name, enter a value. This must be globally unique. Note this in your Notepad the name of the server in the form .redis.cache.windows.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 Location, Select East US.
  5. For Pricing Tier, Select Standard C1
  6. Tick the box for unblocking port 6379
  7. Press OK


Note: this process can take up to 25 minutes to complete. While it is running, you may proceed to the next set of steps.
Back in the Resource Group blade, click Add again and type App Service Plan


Select the top item and confirm it is App Service Plan from Microsoft and then click Create


Fill out the create blade as below.

  1. App Service Plan name
  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 Location, Select East US.
  5. For Pricing, Select S1 Standard
  6. Click OK


While that is running, go back to the Resource Group screen and open up your new MySQL instance. You may have to click the Refresh button on the Resource Group blade to see the contents.
Note the Server admin login name is as you entered it when creating the server with @ after it. Copy and past this value in its entirety into your Notepad session.


Note that SSL enforce status is set to enabled. We’re going to disable that. Click Connection Security on the left-hand side of this blade and make the following adjustments:

  1. Set Allow access to Azure services to ON
  2. Set Enforce SSL connection to DISABLED
  3. Click Save

Note that this process can take up to 2 minutes to save. I suggest you stay on this blade until it is complete (you’ll get a notice in the Alerts window).
Now, if we look back at the Overview tab of the MySQL server, you’ll see SSL enforce status is DISABLED.