다음을 통해 공유


Azure App Service Troubleshooting: PHP application HTTP Error 503 – The service is unavailable

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.

Issue

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-The-service-is-unavailable-wikiazure.png

 

During this downtime I was unable to reach out the SCM / Kudu Console but I could connect via FTP client.

Prerequisites

Before we start troubleshooting this issue consider the following:

  • First of all, enable PHP error log and shared the php_errors.log file from location d:\home\LogFiles
  • You can enable PHP error log in .user.ini file by adding log_errors=On line
  • By default, PHP Errors are located at d:\home\LogFiles\php_errors.log

NoteReference 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:

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-Diagnose-and-Solve-problems-wikiazure.png

 

Diagnose and solve problems will also provide you with the details of the errors you might have in you web app:

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-Diagnose-and-Solve-problems-App-performance-wikiazure.png

 

Troubleshooting

1st workaround: FTP

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.

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-deactivate-plugins-wikiazure.png

 

2nd Workaround: Scale up and scale down

Confirm that there was no Azure App Service platform issue observed during this time:

  • As of writing time I was using S3 Standard Large Azure App Service plan.
  • Try scaling up from S3 to S2 Standard which you will get the working Virtual machine.
  • Once everything starts working you can scale up back to S3 Standard.

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-update-App-Service-Plan-wikiazure.png

3rd Workaround: App Settings

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.

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-config-file-wikiazure.png

 

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.

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-disable-website-private-extensions-wikiazure.png

 

4th workaround: Site Extension

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:

  •  AzureImageOptimizer
  •  Microsoft.ApplicationInsights.AzureWebSites
  •  NewRelic.Azure.WebSites
  •  phpmanager
  •  RedirectHttpToHttps
  •  WPCLIExtension

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:

  • D:\home\site\siteextensions\
  • D:\home\SiteExtensions\
  • D:\home\site\wwwroot\newrelic\

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:

 

https://wikiazure.azureedge.net/wp-content/uploads/2018/01/Azure-App-Service-PHP-application-returning-HTTP-Error-503-remove-site-extension-wikiazure.png