By Scott Johnston – 7/8/2020

While our site is ASP.Net MVC, I installed a WordPress site in a subdirectory to hold all the help information. This makes it easier for the team to update help as they don’t need to re-publish the main site. I think WordPress works great for this purpose as a content management system.

The Problem – Old Version of PHP

ChronoBeans has been around for several years now, and one of the team was updating some plug-in’s for the Help site and found that we were still running an old version of PHP.  Normally when when working with other hosting services this is simply a matter of changing a setting in the control panel, after backup/testing etc.

I’m the first to admit I’m no Azure Portal expert, and I tend to stumble around in there trying to find settings like a miner with a dim headlamp. The look and functionality of the Portal seems to change frequently too – something I discovered when trying to track down a nasty 5xx recently, but that’s a story for another day.  Even when you ask Mr. google, or Ms. yahoo, or even the  supposedly genderless duckduckgo, the myriad of links that appear often contain outdated or obsolete information (note the date at the top of this post!). Sometimes stackoverflow has the goods too. I generally end up going in circles like a Nascar driver but eventually after many laps I can piece together enough snippets to solve most technical problems.  As it was with todays challenge.

The Quick Solution – Updating your PHP Version

In the Azure Portal, open up your Cloud Shell Bash terminal. Didn’t know you had one? Don’t feel bad, neither did I. In the upper right of the title bar there is this icon that will get you there…

This opens you up to the great world of the Azure CLI (Command Line Interface). There is a tiny bit of first time setup (it is Azure after all), including selecting an app service plan for billing of some minor file storage, if you don’t already have this configured.

Next it’s best to check what version of PHP you think you are on. This also validates you are looking at the right resource group and app service. Here is the command to show the version.

az webapp config show –resource-group (your resource group) –name (your app service) –query phpVersion

In my case it returned a disgustingly obsolete “5.6”. Now it’s time to find out what versions of PHP you can upgrade too. Another simple command provides this info.

 az webapp list-runtimes | grep php

In my case I had three choices: “php|7.2”,  “php|7.3”,  “php|7.4”. I just chose the most recent. To install the update it was another simple command to set the configuration.

az webapp config set –name (your app service) –resource-group (your resource group) –php-version 7.4

And that’s that. You can repeat the Config Show command to verify you are on the new version.  All in all a pretty painless update – once you know the commands. Happy coding.