Skip to content

Day 1 Solution : Creating WordPress with MSSQL on Azure Web App and SQL Azure

Step by step guide to setting up WordPress with MSSQL on Azure Web App and SQL Azure

 

Here’s my response to the challenge. The choice of technology which I’m starting with would be WordPress.
Thinking further, I’ve decided to look for CMS fork of WordPress which utilizes MSSQL instead of MYSQL.
This is purely my choice as I’m familiar with MSSQL, knowing that in future the setting up of high availability configuration would be something I’m comfortable with.

There are more than one way to skin cat. Assuming you are intending to utilize WordPress as well, you can definitely spin up an instance of a Virtual Machine, install the LAMP stack, and install WordPress thereafter.

For my choice of selection Project Nami offers a WordPress fork which ties MSSQL to WordPress, and offers it as a template deploy to Azure.
The below button offers a one click deploy to Azure.


Screenshot after clicking “Deploy to Azure” and signing in to Azure, you will be prompted to enter parameters unique to your Azure subscription.

For the first part, ensure that you create a new resource group for separation of concerns. Make sure that you name your subscription group right the first time, as changing it thereafter isn’t as straight forward as it seems (7th Aug 2018 as of point of writing). Choose a site location which is closest to your potential target audience, and remember your SQL Admin login and password. You will need your credentials 4 steps later.

Async updates after clicking “next” on from the previous page. This will take anywhere from 5 – 10 mins.

Click on your site once the creation is done. The site https://30daysofazure.azurewebsites.net is the one which I’ve created. You will need to click on your unique URL for the site which you have generated.

Famous wordpress 5 mins installation: Step 1 Selection of Language

Famous wordpress 5 mins installation: Step 2 entering of credentials

Leave the database name, user name (also know as the SQL Admin login 3 steps earlier), database host as is. For the password, you will need to refer to 3 steps prior. This is the SQL Admin password.

Famous wordpress 5 mins installation: Step 3 confirmation and initiate installation

Famous wordpress 5 mins installation: Installation done

When you are prompted with this page, this means that your installation of wordpress has completed successfully.
Name your site, and enter your default username and password. The above screenshot illustrates the default complex generated password.
When choosing your password, you should utilize upper, lower, unique chars with a high character count.

No. That is not the password which I’ve used.

Signing in to wordpress administrator page

To sign in to your wordpress administrator page, you will need to append /wp-admin or /wp-login.php to your website’s URL
Enter your username and password, there after you should see a similar scene above.

Setting up custom domain under Settings > General

The default wordpress address and site address points to the xxxxx.azurewebsites.net
To utilize your own domain, you will need to change it to the URL similar to the setting below.

*Warning, once you change this and hit save, you will not be able to access your wordpress site unless either of the below conditions are fulfilled.

  1. Point your domain name cname record or A records to 30daysofazure.azurewebsites.net
  2. Use the host file on your local machine to emulate host header passing (this is slight more complex. ignore if you don’t understand)

Remember once you save it, you don’t be able to access your site until you do either of the 2 conditions above.
This marks the end of wordpress for now. Let’s switch over to Azure.

List of services created by Project Nami’s template deploy script

The service which has been created includes an

  • App Service (which is associated with an App Service Plan)
  • A SQL Server which an SQL database reside in

I would like to map a custom domain to my App Service, hence I would need to click on my App Service instance named 30daysofazure > Custom Domains and >Upgrade your App Service Plan

Click here to upgrade your App Service Plan
Different Tiers of selections for App Service

You can either choose Dev / Test or Production level scale. I’m choosing S1 because in addition to custom domain, I’ll be working on enabling SSL for my wordpress site.

Validation of Domain Name ownership

For this specific part, you can register a domain on Azure App Service Domain or you can utilize popular registrars such as godaddy, namecheap etc…

Changing of CNAME and A records on Namecheap

As I’m using namecheap, I’ll be pointing my www host with CNAME record to 30daysofazurewebsites.net
For my naked domain ( @ host ), I’ll be doing either an A record to an IP address or 301 URL Redirect to www.tanchunsiong.com

But, what if one day I decide to change my compute choice and wish to switch to VM? The propagation of DNS used to take up to 48 hours. The domain name registrar in today’s context allows you to set TTL with the shortest span of 1 min. Instead of the possibility of messing around with DNS records in the near future, I’ll be using Traffic Manager (a DNS level load balancer) to redirect traffic from Namecheap to either internal azure resources or external azure resources.

This is an overkill service layer at this point in time, but it will come in useful in near future.

Creation of Traffic Manager Profile on Azure
Setting CNAME record of host www to traffic manager
Impatiently pinging domain name to check propagation of CNAME records.

While waiting for the the CNAME record to propagate, this is a good time to configure Traffic Manager. Creating a new endpoint, you will need to set the endpoint to an Azure Endpoint, of type and target App Service.

Setting up parameters in Traffic Manager Profile
Propagation of DNS records completed

A quick test of the URL allows you to sign in to the wordpress admin site with your new custom domain.
But what if you are using https instead of http?

When using HTTPS instead of HTTP

To enable HTTPS, you will need to get an SSL cert. This is available from Azure, or from various cert authority online. One popular free SSL certificate provider is called Let’s Encrypt.

Check out Scott Burmester’s post on Securing Web App with Let’s Encrypt Web Job Extension

Once you are done, you should have something similar to the architecture diagram below.

Published inUncategorized

Be First to Comment

Leave a Reply

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