Monitor the health of App Service instances - Azure App Service (2023)

  • Article
  • 8 minutes to read

This article uses Health check in the Azure portal to monitor App Service instances. Health check increases your application's availability by rerouting requests away from unhealthy instances, and replacing instances if they remain unhealthy. Your App Service plan should be scaled to two or more instances to fully utilize Health check. The Health check path should check critical components of your application. For example, if your application depends on a database and a messaging system, the Health check endpoint should connect to those components. If the application can't connect to a critical component, then the path should return a 500-level response code to indicate the app is unhealthy. Also, if the path does not return a response within 1 minute the health check ping is considered unhealthy.

Monitor the health of App Service instances - Azure App Service (1)

What App Service does with Health checks

  • When given a path on your app, Health check pings this path on all instances of your App Service app at 1-minute intervals.
  • If an instance doesn't respond with a status code between 200-299 (inclusive) after 10 requests, App Service determines it's unhealthyand removes it. (The required number of failed requests for an instance to be deemed unhealthy is configurable to a minimum of two requests.)
  • After removal, Health check continues to ping the unhealthy instance. If the instance begins to respond with a healthy status code (200-299) then the instance is returned to the load balancer.
  • If an instance remains unhealthy for one hour, it will be replaced with new instance.
  • When scaling out, App Service pings the Health check path to ensure new instances are ready.

Note

(Video) Troubleshooting instance related issues on Azure App Services

  • Health check doesn't follow 302 redirects.
  • At most one instance will be replaced per hour, with a maximum of three instances per day per App Service Plan.
  • If your health check is giving the status Waiting for health check response then the check is likely failing due to an HTTP status code of 307, which can happen if you have HTTPS redirect enabled but have HTTPS Only disabled.

Enable Health Check

Monitor the health of App Service instances - Azure App Service (2)

  • To enable Health check, browse to the Azure portal and select your App Service app.
  • Under Monitoring, select Health check.
  • Select Enable and provide a valid URL path on your application, such as /health or /api/health.
  • Select Save.

Caution

Health check configuration changes restart your app. To minimize impact to production apps, we recommend configuring staging slots and swapping to production.

Configuration

In addition to configuring the Health check options, you can also configure the following app settings:

App setting nameAllowed valuesDescription
WEBSITE_HEALTHCHECK_MAXPINGFAILURES2 - 10The required number of failed requests for an instance to be deemed unhealthy and removed from the load balancer. For example, when set to 2, your instances will be removed after 2 failed pings. (Default value is 10)
WEBSITE_HEALTHCHECK_MAXUNHEALTHYWORKERPERCENT1 - 100By default, no more than half of the instances will be excluded from the load balancer at one time to avoid overwhelming the remaining healthy instances. For example, if an App Service Plan is scaled to four instances and three are unhealthy, two will be excluded. The other two instances (one healthy and one unhealthy) will continue to receive requests. In the worst-case scenario where all instances are unhealthy, none will be excluded.
To override this behavior, set app setting to a value between 0 and 100. A higher value means more unhealthy instances will be removed (default value is 50).

Authentication and security

Health check integrates with App Service's authentication and authorization features. No additional settings are required if these security features are enabled.

(Video) Betatalks #57 - How to set up Health Checks in Azure App Service

If you're using your own authentication system, the Health check path must allow anonymous access. To secure the Health check endpoint, you should first use features such as IP restrictions, client certificates, or a Virtual Network to restrict application access. Once you have those features in-place, you can authenticate the health check request by inspecting the header, x-ms-auth-internal-token, and validating that it matches the SHA256 hash of the environment variable WEBSITE_AUTH_ENCRYPTION_KEY. If they match, then the health check request is valid and originating from App Service.

  • .NET
  • Python
  • Java
  • Node.js
using System;using System.Text;/// <summary>/// Method <c>HeaderMatchesEnvVar</c> returns true if <c>headerValue</c> matches WEBSITE_AUTH_ENCRYPTION_KEY./// </summary>public Boolean HeaderMatchesEnvVar(string headerValue) { var sha = System.Security.Cryptography.SHA256.Create(); String envVar = Environment.GetEnvironmentVariable("WEBSITE_AUTH_ENCRYPTION_KEY"); String hash = System.Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(envVar))); return hash == headerValue;}

Note

The x-ms-auth-internal-token header is only available on Windows App Service.

Monitoring

After providing your application's Health check path, you can monitor the health of your site using Azure Monitor. From the Health check blade in the Portal, select the Metrics in the top toolbar. This will open a new blade where you can see the site's historical health status and option to create a new alert rule. Health check metrics will aggregate the successful pings & display failures only when the instance was deemed unhealthy based on the health check configuration. For more information on monitoring your sites, see the guide on Azure Monitor.

(Video) How to identify and diagnose apps with high CPU: Part 1 | Azure App Service

Limitations

  • Health check can be enabled for Free and Shared App Service Plans so you can have metrics on the site's health and setup alerts, but because Free and Shared sites can't scale out, any unhealthy instances won't be replaced. You should scale up to the Basic tier or higher so you can scale out to 2 or more instances and utilize the full benefit of Health check. This is recommended for production-facing applications as it will increase your app's availability and performance.

Frequently Asked Questions

What happens if my app is running on a single instance?

If your app is only scaled to one instance and becomes unhealthy, it will not be removed from the load balancer because that would take down your application entirely. However, after one hour of continuous unhealthy pings, the instance is replaced. Scale out to two or more instances to get the rerouting benefit of Health check. If your app is running on a single instance, you can still use Health check's monitoring feature to keep track of your application's health.

Why are the Health check requests not showing in my web server logs?

The Health check requests are sent to your site internally, so the request won't show in the web server logs. This also means the request will have an origin of 127.0.0.1 since the request is being sent internally. You can add log statements in your Health check code to keep logs of when your Health check path is pinged.

Are the Health check requests sent over HTTP or HTTPS?

On Windows App Service, the Health check requests will be sent via HTTPS when HTTPS Only is enabled on the site. Otherwise, they're sent over HTTP. On Linux App Service, the health check requests are only sent over HTTP and can't be sent over HTTPS at this time.

Is Health check following the application code configured redirects between the default domain and the custom domain?

No, the Health check feature is pinging the path of the default domain of the web application. If there is a redirect from the default domain to a custom domain, then the status code that Health check is returning is not going to be a 200 but a redirect (301), which is going to mark the worker unhealthy.

What if I have multiple apps on the same App Service Plan?

Unhealthy instances will always be removed from the load balancer rotation regardless of other apps on the App Service Plan (up to the percentage specified in WEBSITE_HEALTHCHECK_MAXUNHEALTHYWORKERPERCENT). When an app on an instance remains unhealthy for over one hour, the instance will only be replaced if all other apps with Health check enabled are also unhealthy. Apps that don't have Health check enabled won't be taken into account.

Example

Imagine you have two applications (or one app with a slot) with Health check enabled, called App A and App B. They are on the same App Service Plan and that the Plan is scaled out to four instances. If App A becomes unhealthy on two instances, the load balancer will stop sending requests to App A on those two instances. Requests will still be routed to App B on those instances assuming App B is healthy. If App A remains unhealthy for over an hour on those two instances, those instances will only be replaced if App B is also unhealthy on those instances. If App B is healthy, the instance won't be replaced.

(Video) Understanding Azure App Services

Monitor the health of App Service instances - Azure App Service (3)

Note

If there were another site or slot on the Plan (Site C) without Health check enabled, it would not be taken into consideration for the instance replacement.

What if all my instances are unhealthy?

In the scenario where all instances of your application are unhealthy, App Service will remove instances from the load balancer up to the percentage specified in WEBSITE_HEALTHCHECK_MAXUNHEALTHYWORKERPERCENT. In this scenario, taking all unhealthy app instances out of the load balancer rotation would effectively cause an outage for your application.

Does Health Check work on App Service Environments?

Yes, health check is available for the App Service Environment v3, but not for versions 1 or 2. If you are using the older versions of the App Service Environment, you can use the migration feature to migrate your App Service Environment to version 3.

(Video) How to Monitor the Published APIs in Azure API Management Instance

Next steps

FAQs

How do I check the health of an Azure application? ›

To enable Health check, browse to the Azure portal and select your App Service app. Under Monitoring, select Health check. Select Enable and provide a valid URL path on your application, such as /health or /api/health . Select Save.

How do I monitor Azure App Service? ›

To review the status of the various quotas and metrics that affect an app, go to the Azure portal. To find quotas, select Settings > Quotas. On the chart, you can review: The quota name.

How will you check how many instances currently running on the App Service? ›

Go into your App Service Plan > Diagnose and Solve Problems > Under "Tools" and can view 'Metrics per instance (App Service Plan)' and 'Metrics per Instance (Apps)' - As the name indicates, Metrics per instance (App Service Plan) displays data for the entire VM, while Metrics per Instance (Apps) displays data for a ...

What are the primary services available for monitoring the health of your apps and resources Azure? ›

Resource Health provides information about the health of your individual cloud resources, such as a specific virtual machine instance. Service Health provides a personalized view of the status of your Azure services and regions, as well as information about current incidents, planned maintenance and health advisories.

What is Azure health monitor? ›

Resource Health provides information about the health of your individual cloud resources, such as a specific virtual machine instance. Service Health provides a personalized view of the status of your Azure services and regions, as well as information about current incidents, planned maintenance, and health advisories.

Which of the following is used to monitor the health of service in an application? ›

Monitor the health of application services in the Application Service Dashboard.

What is the monitoring tools using to Monitor the application in Azure? ›

Microsoft combined three unique services—Azure Monitor, Log Analytics, and Application Insights—under the umbrella of Azure Monitor to provide powerful end-to-end monitoring of your applications and the components they rely on. Log Analytics and Application Insights are now features of Azure Monitor.

How do I view Azure App Service logs? ›

To stream logs in the Azure portal, navigate to your app and select Log stream.

What is the difference between Azure service health and Azure Monitor? ›

Azure Monitor helps you understand how your applications are performing and proactively identifies issues affecting them and the resources they depend on. Azure Service Health helps you stay informed and take action when Azure service issues like outages and planned maintenance affect you.

How do I check what instances I am running? ›

To view the status of a specific instance, select the instance, and then choose the Status checks tab. If your instance has a failed status check, you typically must address the problem yourself (for example, by rebooting the instance or by making instance configuration changes).

What is instance status check? ›

Instance Status checks detect problems within your instance. Typically, these are problems that you as a customer can fix, for example by rebooting the instance or making changes in your operating system.

What is maximum instance in Azure App Service? ›

You can scale out to as many as 30 instances, depending on your pricing tier. App Service Environments in Isolated tier further increases your scale-out count to 100 instances.

Which of the following features services can you use to to Monitor your live applications and automatically detect performance anomalies? ›

Visual Studio Application Insights is an extensible analytics service that monitors your live web application. With it you can detect and diagnose performance issues, and understand what users actually do with your app.

What are the 3 important services offered by Azure? ›

This gives users the flexibility to use their preferred tools and technologies. In addition, Azure offers four different forms of cloud computing: infrastructure as a service (IaaS), platform as a service (PaaS), software as a service (SaaS) and serverless functions.

Which blade should you identify to Monitor the health of Azure services? ›

Azure Monitor is used to monitor the health of Azure services.

What are the three main functions of Azure Monitor? ›

Microsoft combined three unique services—Azure Monitor, Log Analytics, and Application Insights—under the umbrella of Azure Monitor to provide powerful end-to-end monitoring of your applications and the components they rely on. Log Analytics and Application Insights are now features of Azure Monitor.

How do I check my Azure VM health status? ›

The guest health monitoring can be enabled by navigating Azure Monitor > Insights > Virtual Machines. Once the VMs are upgraded, you will find an option, “Health,” where the health explorer is available. It gives you the complete monitoring details and configurations made for this VM.

What is the difference between Azure Monitor and application Insights? ›

Application Insights is an extension of Azure Monitor and provides Application Performance Monitoring (also known as “APM”) features. APM tools are useful to monitor applications from development, through test, and into production in the following ways: Proactively understand how an application is performing.

Which are the three basic tools for monitoring? ›

There are three basic categories of monitoring; technical monitoring, functional monitoring and business process monitoring.

How do I create a monitoring dashboard in Azure? ›

In the menu dropdown on the left in the Azure portal, select Dashboard. On the Dashboard pane, select New dashboard > Blank dashboard. Enter a name for the dashboard. Look at the Tile Gallery for various tiles that you can add to your dashboard.

Where do we see Azure app insights telemetry? ›

View telemetry in Application Insights

To open Application Insights from a function app in the Azure portal: Browse to your function app in the portal. Select Application Insights under Settings in the left page.

What are the two main kinds of data Azure Monitor works with? ›

Overall, Azure Monitor is using two fundamental types of data to work. Those are metrics and logs the tool is collecting into data stores to perform actions such as analysis, alert generation and streaming to connected external systems.

Is Azure Monitor the same as log analytics? ›

Monitor is the brand, and Log Analytics is one of the solutions. Log Analytics and Application Insights have been consolidated into Azure Monitor to provide a single integrated experience for monitoring Azure resources and hybrid environments.

What is EC2 health check? ›

Amazon EC2 status checks and scheduled events. Checks that the instance is running. Checks for underlying hardware or software issues that might impair the instance.

What command should you run on a running instance if you want to view its user data that is used at launch )? ›

To specify user data when you launch your instance, use the run-instances command with the --user-data parameter.

How do I know if I have an instance of instance? ›

You can identify a Spot Instance from the spot value in the Instance lifecycle column. The Instance state column indicates whether the instance is pending , running , stopping , stopped , shutting-down , or terminated . For a hibernated Spot Instance, the instance state is stopped .

What is difference between system status check and instance status check? ›

Ans. System status check is to check if the power or network is working whereas Instance status check goes further and make sure that traffic is going through.

What is instance in performance testing? ›

Instance types comprise various combinations of CPU, memory, storage, and networking capacity and give you the flexibility to choose the appropriate mix of resources for your applications. There of course cost implications for which we discus estimation of those in a related post.

Why do instance status checks fail? ›

An instance status check failure indicates a problem with the instance, such as: Networking or startup configuration issues. Exhausted memory. File system issues.

How will you check how many instances currently running on the app service? ›

Go into your App Service Plan > Diagnose and Solve Problems > Under "Tools" and can view 'Metrics per instance (App Service Plan)' and 'Metrics per Instance (Apps)' - As the name indicates, Metrics per instance (App Service Plan) displays data for the entire VM, while Metrics per Instance (Apps) displays data for a ...

How do I find out how many instances I have in app services? ›

To get an actual instance count metric you have to have an auto-scale rule created for the app service plan. Auto scale rules do have metrics that enable you to track the instance count of the auto-scaled resource (which in this case would be the app service plan). Hope that helps.

How many apps can run on App service plan? ›

You can host up to 100 apps in a single app service plan, but the key thing to know here is that as with the free plan you are charged per app, not per app service plan. Each instance of a web app you deploy in the shared plan get's it's own 240 CPU minutes limit and is charged per app.

What is the monitoring tools using to monitor the application in Azure? ›

Microsoft combined three unique services—Azure Monitor, Log Analytics, and Application Insights—under the umbrella of Azure Monitor to provide powerful end-to-end monitoring of your applications and the components they rely on. Log Analytics and Application Insights are now features of Azure Monitor.

What can be monitored from a service's applications page? ›

You should monitor your cloud based applications for: Identify from the end-user perspective how well cloud service providers deliver performance across different geographies. Troubleshoot performance and availability bottlenecks in the service delivery chain. Independently validate vendors SLA claims with real data.

What are the primary services available for monitoring the health of your apps and resources in Azure? ›

Resource Health provides information about the health of your individual cloud resources, such as a specific virtual machine instance. Service Health provides a personalized view of the status of your Azure services and regions, as well as information about current incidents, planned maintenance and health advisories.

What are the 4 service categories provided by Microsoft Azure? ›

A public cloud computing platform, Microsoft Azure offers infrastructure as a service (IaaS), software as a service (SaaS), platform as a service (PaaS), and a serverless model.

Which of the following features services can you use to to monitor your live applications and automatically detect performance anomalies? ›

Visual Studio Application Insights is an extensible analytics service that monitors your live web application. With it you can detect and diagnose performance issues, and understand what users actually do with your app.

What is application health check? ›

Overview. An app health check is a monitoring process that continually checks the status of a running app. Developers can configure a health check for an app using the Cloud Foundry Command Line Interface (cf CLI) or by specifying the health-check-http-endpoint and health-check-type fields in an app manifest.

How do I monitor application logs in Azure? ›

In the left navigation, click on Diagnose and solve problems – Checkout the tile for “Diagnostic Tools” and “Availability and Performance” > "Application Logs" title. With the new Azure Monitor integration, you can create Diagnostic Settings (preview) to send logs to Storage Accounts, Event Hubs and Log Analytics.

How do I monitor the performance of my Azure function? ›

Azure Functions can be monitored using Application Insights and Azure Monitor. Though Azure provides such monitoring solutions, users cannot monitor multiple entities with various metrics. Whereas, with Serverless360 monitoring, it is possible to monitor various entities based on metrics at the Application level.

How do I monitor Azure resources? ›

You can access Azure Monitor features from the Monitor menu in the Azure portal. You can also access Azure Monitor features directly from the menu for different Azure services.

Which blade should you identify to monitor the health of Azure services? ›

Azure Monitor is used to monitor the health of Azure services.

What is Azure service health? ›

One such resource is the Azure service health which notifies the user about the availability and health status of each resource in different Azure regions. Azure service health encompasses three different features: Azure Status, Service Health, Resource Health.

What can Azure Monitor do? ›

Azure Monitor helps you maximize the availability and performance of your applications and services. It delivers a comprehensive solution for collecting, analyzing, and acting on telemetry from your cloud and on-premises environments.

How do you monitor the health of Microservices? ›

To monitor the availability of your microservices, orchestrators like Kubernetes and Service Fabric periodically perform health checks by sending requests to test the microservices. When an orchestrator determines that a service/container is unhealthy, it stops routing requests to that instance.

Which log is used to monitor System and application activities? ›

Windows event logs. Windows event logs are a record of everything that happens on a Windows system. This log data is further classified into: Windows application logs: These are events logged by the applications in the Windows operating system.

What is Azure monitor application insights? ›

Application Insights is an extension of Azure Monitor and provides Application Performance Monitoring (also known as “APM”) features. APM tools are useful to monitor applications from development, through test, and into production in the following ways: Proactively understand how an application is performing.

Videos

1. Azure App Service (Web Apps) Tutorial
(Adam Marczak - Azure for Everyone)
2. Diagnosing application crashes with Azure App Services
(Microsoft Azure)
3. Azure Private Endpoints (Private Link) with services like App Services, SQL, and Storage Accounts
(Atmosera)
4. How to secure your Azure App Services
(dotnetFlix)
5. Azure app service tutorial | AZ 204 Azure app services full course
(Tech of the day)
6. Azure Service Health
(Travis Roberts)
Top Articles
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated: 01/09/2023

Views: 6204

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.