App Service PHP-Version Update

From time to time, every website needs an update. This may be in terms of content, or the system in the background. For example, you should always use the latest PHP version whenever possible. In this blog post I will show you how you can easily and quickly perform an Azure App Service PHP version update on Azure, via GUI or CLI.

Preparation of the App Service

As usual, an update or upgrade is not free of risks. To be safe, test the procedure first on a test system that is as identical as possible, as you usually do. Since you are using Azure App Service, this is easy. Simply create the App Service test environment using the current backup. The following blog post shows you how to do this in just a few steps. https://www.graber.cloud/restore-appservice-mysql-inapp-db/

Note: If you want to perform the update in the productive environment, you should communicate a maintenance window. Although the upgrade can be performed while the system is running, it will result in an automatic restart. In addition, system errors can never be 100 percent prevented despite testing.

The update is very easy to perform. Below you will find the instructions on how to perform the update via GUI, or via CLI.

Update App Service PHP version via GUI

To perform the update via GUI, first navigate in the Azure portal to the corresponding app service or deployment slot that you have provided for the test. In this example, the deployment slot named "Dev". Then navigate to "Configuration" and select "General Settings". Here you will find the dropdown list named "PHP version" which contains all supported PHP versions. Select the current one and confirm with "Save".

After just a moment, your app service should be updated to the latest version.

Check if the update was successful and your app service works as desired and correctly. If you were able to run all tests according to your test protocol successfully and without any problems, you are ready to run the update in your production environment.

Update App Service PHP version via CLI

The update of the PHP version can also be done via CLI, using a one-liner. You can find the documentation for the CLI commands under this Link on docs.microsoft.com.

In my example, I use the Cloud Shell directly in the Azure Portal. Run the following command to get the current PHP version of your app service. Make sure to use the "slot" parameter to test the update first before going to the production environment.

az webapp config show --resource-group <rg-name> --name <AppServiceName> 
--slot <TestSlotName> --query phpVersion

Then configure the desired PHP version with the following command.

az webapp config set --resource-group <rg-name> --name <AppServiceName> --slot <TestSlotName> --php-version 7.4

If you now query the PHP version again, you will see the new version.

Check if the update was successful and your app service works as desired. If everything is in order and as desired, you can perform the update on the productive environment. Proceed in exactly the same way, but remove the parameter "slot" and its value from the CLI commands. For example as follows:

az webapp config set --resource-group <rg-name> --name <AppServiceName> 
--php-version 7.4

1 thought on “App Service PHP-Version Update”

Leave a comment

en_GBEnglish