Are you looking to create your very own Scalable optimized WordPress Site/blog using Azure MySQL, Azure Storage and Azure CDN, then this post series is for you?
I have divided the series into below parts:
- Getting Azure Subscription, Creating App Service Plan and WordPress Web Service using My SQL In App
- Connecting Word Press website with WordPress.com and Installing and configuring Jet Pack
- Creating Azure Database for MySQL and exporting the Data from My SQL In App to Azure Database for MySQL Server, Handling Security and Optimizing with persistent connection
- Creating Azure Storage Account and configuring WordPress to use Azure Storage to store media files and Optimizing with persistent connection.
- Configuring Custom domain, SSL Certificates.
- Configuring CDN, configuring back up scheduling in azure and Auto Scaling
- How to use REDIS CACHE with WORDPRESS on Azure
- How to install application insights in WordPress on Azure
If you are not following along please check the previous part 1 first.
At this point, your site is connected with WordPress.com, configured Custom Domain and enabled SSL on our newly created WordPress site. We are moving to next part, which is Configuring CDN, backup and Auto Scaling for our site.
Let us go to Azure Portal and navigate your App Service, click on “Networking” under settings and choose “Configure Azure CDN for your App”
Figure 1 Configure Azure CDN for Your app
Now you need to fill out the form accordingly, and choose the pricing tier, we are going for “S2 Standard Akamai”, since in our testing we found out that Akamai is performing very well in our region as compared to “Verizon”, you may need to test it to get the idea regarding your Region.
If you want to learn more about CDN https://docs.microsoft.com/en-us/azure/cdn/cdn-overview
Figure 2 Create Azure Content Delivery Network Profile
It may take a few minutes to create a profile, once the profile is created, go to profile, you can see that it created an endpoint that you had mentioned while creating the profile.
Figure 3 CDN endpoint is created
Click on the endpoint, now we can see that it is pointing to our website, all we need to do is now to configure “WordPress” site to use this end point while delivering content.
Figure 4 CDN endpoint is created
Now go to your “WordPress” dashboard and click on plugins and then “Add Plugins”, search for CDN and install “CDN Enabler” plugin.
Once installed go to plugin from settings-> CDN Enabler. Copy the endpoint URL that you have created earlier and paste in CDN URL, if your website is running on SSL then Check CDN HTTP option and click save.
Now when you access your site, make sure to go to Developer Tools and then network tab, you will see file are loaded from CDN for wp-content and wp-includes directory, which are mostly Theme related files.
We can go even one-step ahead and load our Media file from CDN. Let us go back to CDN profile and create a new endpoint, this time it will point to our public container on Azure Storage in which our media files are stored. Click on EndPoint button:
Figure 5 Create new endpoint in CDN profile
Now fill out the name and choose “Storage” in Origin type and also choose your blob storage point in “Origin host header”, choose Optimized for as “General web delivery”. You can choose this option according to your needs, since we are using it for website so General Web Delivery will do it.
Figure 6 Add an Endpoint
Once the endpoint is created, go back to the word press site dashboard and then settings->Microsoft Azure, and put the endpoint URL in the CNAME and click save, now test the site you will find out that your media will be loaded from the CDN endpoint. Remember if you have configured custom domain in CDN itself then it will take some time to propagate the changes.
Figure 7 configure CDN for Media files
It is very important to take backup of your site especially now a days, when we are facing a lot of security challenges and business requirement. Go to Azure portal and then to your App Service, click on Backups under settings heading, since we have not configured any backup yet, it is about time to configure it, click on Configure button.
Figure 8 configure Backup
Now our first task is to create a private container for backups and choose it to store our backup. Switch Scheduled backup to ON and configure the timing when it is suitable to your business needs, usually we choose the time when we expect least amount of user traffic to our site and click save. We do not need to include database backup as it is already been backup in Azure SQL.
Figure 9 Schedule Backup
Figure 10 Create private container for backup
Figure 11 Select Private container for backup
If you want to learn more about backups https://docs.microsoft.com/en-us/azure/app-service/web-sites-backup
Now one more important thing is remaining which is auto scale, Go to App Service click on Scale out (App Service Plan) under settings.
Figure 12 Scale out (App Service Plan)
This option is when you do not want to enable auto scale but need a certain number of instances up all the time, in this case just increase the instances and click save. Addition cost may occur.
Figure 13 Choose instance count
We will go for auto scale option as we are interesting in value of auto scale functionality provided by Microsoft on Azure, Now choose the options according to your needs, we are adapting for default, which are, it will increase by “1” instance if the CPU Average usage percentage is greater than 70.
In addition, Instance Limits Default number of instance will kick in if there is any problem reading matric data, so make sure it is set to your business needs, click save.
You can also see the history of the auto scale and can configure it to notify you when this happens.
You can learn more at https://azure.microsoft.com/en-us/resources/videos/scale-a-web-app-using-azure-scale-out/
Figure 14 Configure auto scale
Congratulations! You have configured your fully secure and scalable WordPress site, which will deliver secure, ultra-fast content with auto scale and worry free backups of your site. I hope you enjoying this series, please convey me your suggestions and comments, and best of luck. coming up next How to use REDIS CACHE with WORDPRESS on Azure