The Azure App Service offers the possibility to have backups created automatically by Azure. This backup also includes the MySQL in-app database, which is often used for a simple WordPress site. But when testing the restore, the surprise that WordPress needs to be reinstalled. This is because the database is not restored during the restore, only the backed up file structure. But more about that later. The following tutorial shows how you can test what problem occurs and how restoring the Azure App Service MySQL in-app database works anyway.
Deployment slot to restore the app service
This guide assumes that you have already successfully set up the App Service backup.
If that's not the case, you can check out this link to learn how to set one it up in just a few steps!
Open the app service for which you want to check the backup and restore. Then create a new deployment slot, or use an already existing one. In this example I use the already existing slot "ygr-tech-blog-Dev". Then assign Traffic as a percentage to the slot, for example 20.
Restore the App Service
Now restore the app service to the deployment slot prepared earlier. Navigate to the menu item Backup and select Restore.
Now select the desired backup in the dropdown, which you want to restore and test. Under "Restore destionation" it is now extremely important that you select "New or existing app". In addition, you must make sure that you select the correct deployment slot in the following dropdown. Check the setting again to make sure you don't overwrite anything you still need, and a data loss results from that! At "Ignore Conflicting Hostnames on Restore" you select "Yes" and start the restore.
Once you see the message that Azure has successfully completed the restore, open the URL of the deployment slot in the browser of your choice. You will now notice that you are redirected to "/wp-admin/install.php" and you need to reinstall WordPress.
This is where restoring the app service MySQL In-App database comes into play.
MySQL In-App database recovery check
To check the MySQL In-App database, first go to the appropriate deployment slot, select "MySQL In-App" and then "Manage".
In the new tab you are now connected to the MySQL In-App database and can check it. By clicking on "localdb" you will see that this database is completely empty and has not been restored.
Keep this tab open, because you will need it again later. For restoring the MySQL In-App database you now need to follow additional manual steps.
I've already submitted feedback to Microsoft that restoring the in-app database should be available as an option. If you'd like to support the idea, you can vote at this link.
Restore of App Service MySQL In-App Database - Customer Feedback for ACE Community Tooling (azure.com)
Manually restore the app service MySQL In-App database
To restore the database manually, you need to download the corresponding backup. To do this, switch back to the original deployment slot (production) on which you configured the backup. Then select the desired backup under "Backups" and download it to your local computer via "Download".
Check the downloaded ZIP file if it contains a file named "LocalMySqlDatabase.sql". If it does not, the Azure backup did not back up your database. However, the MySQL In-App database should always be automatically included in the backup. If the file is present, extract this file from the ZIP and continue.
Next you will import the database file from the backup manually. To do this, go back to the MySQL database tab, select the "localdb" on the left side, click on "Import" at the top and select the previously extracted database file in "Choose File". Then start the import of the database.
After a few moments the success message of the import job appears. Now open the URL of the deployment slot again in the browser of your choice. You will now notice that you are no longer redirected to "/wp-admin/install.php" and therefore no reinstallation of WordPress is necessary. You have successfully validated your backup and restore of the Azure App Service MySQL In-App database.
I recommend performing this test regularly to continuously check the functionality of the backup as well as the restore.
The backup of the Azure App Service, as well as its restoration, is very reliable and simple in my opinion. The fact that the MySQL In-App database is automatically backed up directly is very good. However, the whole thing would be even more helpful if this backup of the database could also be included directly during the restore. So this would save the additional manual effort. I have already placed a corresponding feedback with Microsoft, see here!