This article will show you how to troubleshoot on this issue: “Azure App Service PHP application returning HTTP Error 503 – The service is unavailable” to determine the reason behind the above problem and provide suitable recommendations for the same.
During this downtime I was unable to reach out the SCM / Kudu Console but I could connect via FTP client.
Before we start troubleshooting this issue consider the following:
Note: Reference to enable PHP error log:https://blogs.msdn.microsoft.com/azureossds/2015/10/09/logging-php-errors-in-wordpress-2/
You could also enable “Diagnose and solve problems” option in the App Service blade, this will give you a quick assessment on your web app:
Diagnose and solve problems will also provide you with the details of the errors you might have in you web app:
Connect to your site via ftp client and rename the plugins name for example “plugins-deactivated” . This will deactivate all the plugins. stop/start your webapp.
Confirm that there was no Azure App Service platform issue observed during this time:
For this specific case, the EventLogs for the Web App showed a repeating configuration failure:
Config section 'system.webServer/runtime' already defined. Sections must only appear once per config file.</Data><Data>\\?\ C:\DWASFiles\Sites\wikiazure\Config\applicationhost.config
This error was preventing the Web App processes from starting up, thus the 503 service unavailable.
You should be able to find this error under “\LogFiles\EventLog.xml” if you FTP connect to the Web App itself (remember that SCM site was unreachable).
Check if you are using the “Composer” site extension at all, or any “applicationHost.xdt” file
Also check any Web.config files for duplicate “system.webServer/runtime” sections.
Then go to your web app settings and enable the “WEBSITE_PRIVATE_EXTENSIONS” with value = “0” then stop/start the web app.
Doing some digging on this and found a few previous reports of this same error message “Config section ‘system.webServer/runtime’ already defined”, one example is this forum post:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a05ebcbc-b5b3-4584-bdca-aa9cc00a5685/wordpress-site-http-error-503-the-service-is-unavailable?forum=windowsazurewebsitespreview.
In each case the issue seems to be related to a malfunctioning Site Extension, check if you have anything related to Application Insights/New Relic/Gulp extension on your Web App.
If you FTP connect to the app, you can check if any files exist under D:\home\site\siteextensions\ or D:\home\SiteExtensions\.
In this case, I was using this extensions:
Are you actually using either the New Relic/Application Insights extensions at all on this site? According to previous history the New Relic extension is incompatible with PHP sites, try removing all the New Relic files from:
This site extension is known to have configuration files which can impact the site.
You should also be able to remove New Relic from the “Extensions tab” of the Web App in the Azure portal. Delete the New Relic extension, restart the Web App: