Azure Cloud

How to install Application Insights in WordPress on Azure : Part 8

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:

  1. Getting Azure Subscription, Creating App Service Plan and WordPress Web Service using My SQL In App
  2. Connecting Word Press website with WordPress.com and Installing and configuring Jet Pack
  3. 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
  4. Creating Azure Storage Account and configuring WordPress to use Azure Storage to store media files and Optimizing with persistent connection.
  5. Configuring Custom domain, SSL Certificates.
  6. Configuring CDN, configuring back up scheduling in azure and Auto Scaling
  7. How to use REDIS CACHE with WORDPRESS on Azure
  8. How to install application insights in WordPress on Azure

If you are not following along please check the previous part 1 first.

Application Insights is a good way to measure the performance of the Web site, also provide interactive data on Azure portal. Microsoft have also provided integration with Machine Learning. Application Insights have built in support for Asp.net development all you need to do is install the nugget package and enable it on the App Service and you are good to go.

The question arises how to enable Application Insights when you have WordPress Website on Azure, well this is what we answer today.

In order to configure Application Insights you need to do following:

  1. Install Application Insights plugin from WordPress Plugins
  2. Create Application Insights in Azure Portal or through App Service Application Insights
  3. Get and Configure the Instrumentation Key
  4. Access the website and look for details

  1. Install Application Insights plugin from WordPress Plugins, since I have installed and activated already so it is showing Active, for you it will show Install new.

Figure 1 Search for Application Insights in WordPress plugin

Now go to WordPress | Settings | Application insights; you can see that it requires Instrumentation Key.

Figure 2 Application Insights in WordPress

  1. Create Application Insights in Azure Portal or through App Service Application Insights

Go to Azure Portal, Click on new | search for Application Insights | select Application Insights | fill the form and choose Application Type as General and make sure that your application Insight location match the Location of your Service App and click on create. It may take some time to create it.

Figure 3 Application Insight Creation.

  1. Get and Configure the Instrumentation Key

Now to newly created application insight and in the overview window you will get the Instrumentation Key. Copy the Key and go to WordPress | Settings | Application insights and put the instrumentation key and click save.

Figure 4 Get Instrumentation Key

  1. Access the website and look for details

Now go to Application Insight Overview and see the traffic analytics. You may need to wait for some time to get the initial data.

Figure 5 Health of Application in Application Insights

For more information on Application Insights.

Azure Cloud

How to use Redis Cache with WordPress on Azure : Part 7

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:

  1. Getting Azure Subscription, Creating App Service Plan and WordPress Web Service using My SQL In App
  2. Connecting Word Press website with WordPress.com and Installing and configuring Jet Pack
  3. 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
  4. Creating Azure Storage Account and configuring WordPress to use Azure Storage to store media files and Optimizing with persistent connection.
  5. Configuring Custom domain, SSL Certificates.
  6. Configuring CDN, configuring back up scheduling in azure and Auto Scaling
  7. How to use REDIS CACHE with WORDPRESS on Azure
  8. How to install application insights in WordPress on Azure

If you are not following along please check the previous part 1 first.

Now days it is very important to deliver your content as fast as you can deliver, in the world of performance Redis Cache have significantly gained the traction when it comes to quick response in milliseconds.

Since we are using Azure, it is very simple to use Azure Redis Cache with WordPress on azure. It start with creating an instance on your azure subscription and make sure to create it on same datacenter in which your App Service resides.

Go to Azure Portal click on add button, search for Redis Cache, fill the form and choose your Pricing tier according to your needs and click on create. It could take some time it to provision.

Figure 1 Create Azure Redis Cache for WordPress

Now go to your WordPress Dashboard and search for Redis Cache, you will find a Plugin with name Redis Object Cache, click on Install Now to install it. Once you are done, we need to install the plugin to our Azure App Service.

Figure 2 Install Redis Object Cache

Now go to below link and get the appropriate version of the plugin, in my case my PHP version is 7.1 you can see your by going to App Service | Application Settings | PHP Version

https://pecl.php.net/package/redis

Figure 3 get the plugin for Redis Object Cache

Now extract and Go to KUDU, App Service | Development Tools | Advanced Tool | GO, then click on Debug console | CMD and then click on site | siteextensions, you could see the path in CMD windows as D:homesitesiteextensions. Drag and drop the php_redis.dll here

Figure 4 Upload php_redis.dll to site extensions

Now create a folder in D:homesite as “ini” and create new file in it as “extensions.ini” and put this text in there and save

; Enable Extensions

extension=d:homesitesiteextensionsphp_redis.dll

Figure 5 Create ini folder with extensions.ini file

Figure 6 edit extensions.ini file

Now activate the Redis plugin from WordPress and after that go to WordPress | Settings | Redis and click diagnostics link. Right now, we have not modified wp-config.php file to put the required configuration so it will show Redis: Not Found. Let us do that now.

Figure 7 Redis Object Cache Diagnostics

Go back to KUDU, and navigate to d:homesitewwwroot and then edit wp-config.php and copy paste below code and do not forget to mention configuration highlighted as blod.

// Redis Cache plugin configuration

define(‘WP_REDIS_SCHEME’, ‘tcp’);

define(‘WP_REDIS_HOST’, ‘<redishost>‘);

define(‘WP_REDIS_PORT’, ‘6379’);

define(‘WP_REDIS_DATABASE’, ‘0’);

define(‘WP_REDIS_PASSWORD’, ‘<yourpass>‘);

define(‘WP_CACHE_KEY_SALT’, ‘<prefix>’);

Figure 8 Edit Wp-config.php

You can get the hostname and password from Redis Cache Overview as shown below. For password click on keys and use primary key.

Figure 9 Redis Cache Dashboard

Now click on Enable Object Cache, and wait for some time to enable it, after some time it will load the configuration and it will show you the status connected. If for some reason you it do not show connected then click on show diagnostics and enable disable object cache a few times.

Figure 10 Redis Cache is enabled.

Congratulations, you have successfully configured the Redis Cache with WordPress on Azure.

coming up next How to install application insights in WordPress on Azure

Azure Cloud

Configuring Custom domain, SSL Certificates: PART 5

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:

  1. Getting Azure Subscription, Creating App Service Plan and WordPress Web Service using My SQL In App
  2. Connecting Word Press website with WordPress.com and Installing and configuring Jet Pack
  3. 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
  4. Creating Azure Storage Account and configuring WordPress to use Azure Storage to store media files and Optimizing with persistent connection.
  5. Configuring Custom domain, SSL Certificates.
  6. Configuring Azure CDN, configuring back up scheduling in azure and Auto Scaling
  7. How to use REDIS CACHE with WORDPRESS on Azure
  8. 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 now we are moving to part , which is related to configuring Custom Domain and enabling SSL on our newly created WordPress site.

First, you need to get a domain from domain provider, I usually use Godaddy.com as they have very good integration with Azure and even you can purchase the domain from Godaddy.com within Azure itself.

We assume that you have purchased and own the domain and you have access to the Domain Manager or DNS control panel, below is the domain manager of the Godaddy.com

Godaddy.com Domain Manager or DNS control panel
Godaddy.com Domain Manager or DNS control panel

Figure 1 Godaddy.com Domain Manager or DNS control panel

Now in order to configure the Custom Domain go to your app and then settings-> Custom domains, as you can see Azure provide you the option to purchase the Domain with in the Portal itself.

 Custom Domains
Custom Domains

Figure 2 Custom Domains

You need to put two records in the DNS Manager of your domain

  1. ARecord
  2. CName
  3. TXT Record

A Record with the IP address of the Web App, as you can see in above picture and CName with website URL, in my case it is wordpressite1.azurewebsites.net

Adding A Record
Adding A Record

Figure 3 Adding A Record

I have put an A record in the DNS manager with IP address.

Adding CNAME record
Adding CNAME record

Figure 4 Adding CNAME record

In addition, I have put the CNAME against www subdomain, in case you do not know www is subdomain i.e. scientist.com is main domain and www.scientist.com have www as subdomain. WordPresssite1.azurewebsites.net is specified in my case your case could be different.

Adding CNAME record
Adding CNAME record

Figure 5 Adding TXT Record

I also put a txt record for the main site as you can see above.

Once you are done with this, go back to azure and click on “Add hostname”, below window will open up mention your domain name and click on validate, remember Godaddy.com have good integration with Azure, so it will take few seconds to complete the validation process. For you it may take more time as it take some time to propagate the DNS settings to the world.

Below is for www.scientistz.com this will check for CNAME record validation.

Adding host name
Adding host name

Figure 6 Adding host name

For my Root site validation, which is scientistz.com, this will check for the A record.

Adding Root Site as hostname
Adding Root Site as hostname

Figure 7 Adding Root Site as hostname

Once validation is completed. Browse your site and check if everything work fine. For more information about the configuration, check this link

https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain

Now we assume everything just worked fine for you, let us move to SSL part, this part is very simple, all we have to do is Purchase a SSL certificate, upload to the Azure and add bindings and enable the Https settings for the site that is set.

Although before purchasing the certificate, make sure what is your requirement, if you want the certificate only for your domain and you do not have any plan to create sub domain, then purchase normal certificate, if you are planning to create multiple subdomains then you may need to go with wild card certificate. Azure accepts PFX certificate, you may need to convert the certificate or other types for example .CER to .PFX

You can follow below link if you need any help in this.

https://www.codeheight.com/Blog/Jan2017

https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-ssl#bind-your-ssl-certificate

Uploading SSL Certificate
Uploading SSL Certificate

Figure 8 Uploading SSL Certificate

After you uploaded certificate, you need to add bindings for our site.

Adding SSL bindings
Adding SSL bindings

Figure 9 Adding SSL bindings

After adding the SSL binding now we just need to enable the HTTPS settings. Go to Custom domains and click on “On” button in against HTTPS Only option. This option will redirect all request received on HTTP to HTTPS.

Enabling HTTPS redirection
Enabling HTTPS redirection

Figure 10 Enabling HTTPS redirection

Access your site that everything is working fine there

Congratulations, you have successfully configured custom domain as well as SSL certificate for your site, upcoming next Configuring CDN, configuring back up scheduling in azure and Auto Scaling