Azure App Service is a fully managed platform-as-a-service (PaaS) offering from Microsoft Azure. It supports various programming platforms, including .NET Framework and .NET Core, and features built-in infrastructure, security patching, and scaling. The service enables developers to build, deploy, and scale web applications and APIs easily, making it useful to host .NET applications.
However, despite its helpfulness, users may encounter issues using Azure App Service, including startup failures like HTTP errors, process crashes, and application-level errors. These failures can lead to dissatisfied customers and financial loss.
This article discusses common App Service startup failures, their consequences, and how you can troubleshoot them.
When working with Azure App Service, developers are likely to encounter three common types of startup failure:
While these are not the only potential causes of startup failures, your typical startup failure typically falls into one of these categories. Each of these failures can impact the deployment and performance of a .NET application—reducing scalability, diminishing user experience, increasing response times, and disrupting availability. Let’s explore how to resolve them.
When an HTTP request fails, the web server returns an HTTP error—a three-digit status code that tells you what went wrong. Perhaps the client’s request was incorrect or unsupported, or there was an error in the code or unfindable resources.
Some errors can directly impact the functionality of the application you have hosted on the Azure App Service. For example, client errors (4xx) can prevent users from accessing certain resources or performing specific actions, and server errors (5xx) can cause the application to crash or become unavailable. HTTP errors, like 400 Bad Request or 503 Service Unavailable, negatively impact the user experience.
If your application frequently returns these errors, especially 4xx, it can adversely affect your search engine rankings and site indexing. Search engines will interpret frequent errors as evidence that your site is unreliable and reduce your visibility in search results accordingly.
You can use App Service Diagnostics to diagnose HTTP errors in Azure App Service. First, open the Azure portal and navigate to your Azure App Service. In the left-hand menu, click Diagnose and solve problems to open the App Service Diagnostics blade.
Fig. 1: Azure Portal displaying the App Service Diagnostics bladeNow, in Troubleshooting categories, click Availability and Performance. This page will display recent HTTP status codes your app encountered, along with an overview of the error distribution and the most common error codes, like the screenshot below.
Fig. 2: Azure Portal displaying the Availability and Performance bladeIn the example here, when you hover over the 05:15 point on the timeline (as the bottom of the image above shows), you’ll learn that the following HTTP codes were returned:
Ten minutes later, at 05:25, there were three occurrences of HTTP5xx errors:
Fig. 4: Request counts for each of the resulting HTTP codes over timeNow, click the FailedRequests tile (highlighted on the left in the image below) to open the Web App Down blade.
From there, the Observations and Solutions expandable panel lists the various errors, giving you basic information about each and options to investigate them further. For example, the image below shows .Net Core startup failures, HTTP Server Errors, Web App Restarted, Application Changes, and HTTP 4xx Errors.
Fig. 5: Observations and Solutions panelClick View Details on .NET Core Startup Failures to open a blade with recommended steps. In this case, it recommends inspecting the exceptions in the Application Exceptions table to determine if the errors result from user code and using the Code Snippet or Exception Message to determine the cause of the exceptions. The details also note that the application will be down until you resolve the exceptions.
Fig. 6: Exception details from a .NET Core startup failureExpand HTTP Server Errors for more information about the errors and troubleshooting methods, like the screenshot below.
Fig. 7: Details from an HTTP server errorClick View Details to identify all the failed requests for the app and some standard solutions to resolve these errors. In the example above, HTTP Error 500.30 typically indicates an issue with the underlying ASP.NET Core runtime configuration in Azure App Service. Always ensure your application runs the .NET version that Azure App Service targets.
Expand HTTP 4xx Errors for more information about the 4xx errors the app encountered. In this case, as the screenshot below shows, there were two 404 errors where the requested resource was not found.
Fig. 8: Details from an HTTP 404 errorNow, click View Details to view all the HTTP 4XX requests for the app. This screen also offers some standard methods to investigate and resolve HTTP 4XX errors, which can result from incorrect URLs, connection strings, or missing resources. So, take the time to ensure that the requested resources exist and are properly referenced.
Process crashes significantly impact Azure App Service startup, causing the app service to shut down. When a process within the app service crashes, it fails to execute its tasks, triggering a chain reaction that can affect the service’s stability and functionality. By carrying out effective diagnosis and remediation whenever you experience a process crash, you can optimize the stability of your Azure App Service.
Take the following steps to diagnose process crashes using Azure's log streaming service and application diagnostics:
Here are some practical solutions to fix process crashes in Azure App Service:
To enable logging, navigate to App Service Logs under Monitoring on the left pane:
Fig. 9: App Service Logs on the Web App resourceYou can enable logging into the Web App’s file system or a blob storage container. For this exercise, set Application Logging (Filesystem) to on and the Level to Error:
Fig. 10: Configuring Application Logging and Detailed error messagesApplication-level errors occur within the application code. When an application fails to handle a problem that it encounters and cannot recover from the failure, the app service can unexpectedly crash or shut down. There are several possible causes for these errors, including bad programming practices, errors and exceptions arising from the code during runtime, and configuration problems.
Application-level errors are frustrating for both developers and users. So, to maintain good uptime and reliability, you must quickly identify and address them.
Diagnostic tools such as Azure Application Insights and Azure Log Analytics enable you to identify application-level errors with detailed logs, metrics, and telemetry data. With these logs, you can pinpoint code-level issues such as exceptions, bugs, and incorrect data processing, along with configuration problems, like misconfigured dependencies or incorrect settings. You can then debug, implement proper error handling, or improve data validation to fix the underlying code issues. Updating configuration settings, ensuring accurate connection strings, or adjusting dependencies can also help resolve configuration problems.
Follow these best practices to avoid common startup failures in Azure App Service:
This article examined the common causes of HTTP errors, process crashes, and application-level errors. We looked at the best practices to avoid startup failures, including proper configuration and dependencies, error handling and logging mechanisms, monitoring application health, regular testing and validation, and enabling CI/CD for seamless updates.
To troubleshoot a startup failure in Azure App Service, you need to fully understand the causes of that failure. By following the steps outlined in this article, you can diagnose and resolve startup failures, improving the overall performance and stability of your Azure App Service.
Write for Site24x7 is a special writing program that supports writers who create content for Site24x7 “Learn” portal. Get paid for your writing.
Apply Now