admin管理员组

文章数量:1393035

I setup an Azure Web App using express.js with TypeScript. It implements a health check endpoint. The auto-scaling feature is enabled for the Web App.

const router = express.Router();
router.get('/admin/host/ping', function (_req: Request, res: Response): void {
  res.status(200).end();
});

I set the Health probe path in the portal to /admin/host/ping.

In the HTTP Logs (via diagnostic settings) I found requests with GET method which succeeded (port 443/https) but also with POST method (port 80/http), which obviously responded with 404. The Logs show HttpScaleManager as UserAgent, which seems an Azure client.

I found no details about the required HTTP methods and its usage at Monitor App Service instances by using Health check.

How should a proper health endpoint implementation for Azure Web Apps look like? Is there any documentation about it?


Update: I found a hint at Automatic scaling in Azure App Service in the section Why does AppServiceHTTPLogs have log entries similar to "/admin/host/ping" with a 404 status.

However, it's important to note that these 404 errors shouldn't affect your app's availability or scaling performance.

If your web app returns a 5xx status, these endpoint pings may result in intermittent restarts, though this is uncommon. We are currently implementing enhancements to address these intermittent restarts. Until then, please ensure that your web app doesn't return a 5xx status at this endpoint. Please be aware that these ping endpoints can't be customized.

I setup an Azure Web App using express.js with TypeScript. It implements a health check endpoint. The auto-scaling feature is enabled for the Web App.

const router = express.Router();
router.get('/admin/host/ping', function (_req: Request, res: Response): void {
  res.status(200).end();
});

I set the Health probe path in the portal to /admin/host/ping.

In the HTTP Logs (via diagnostic settings) I found requests with GET method which succeeded (port 443/https) but also with POST method (port 80/http), which obviously responded with 404. The Logs show HttpScaleManager as UserAgent, which seems an Azure client.

I found no details about the required HTTP methods and its usage at Monitor App Service instances by using Health check.

How should a proper health endpoint implementation for Azure Web Apps look like? Is there any documentation about it?


Update: I found a hint at Automatic scaling in Azure App Service in the section Why does AppServiceHTTPLogs have log entries similar to "/admin/host/ping" with a 404 status.

However, it's important to note that these 404 errors shouldn't affect your app's availability or scaling performance.

If your web app returns a 5xx status, these endpoint pings may result in intermittent restarts, though this is uncommon. We are currently implementing enhancements to address these intermittent restarts. Until then, please ensure that your web app doesn't return a 5xx status at this endpoint. Please be aware that these ping endpoints can't be customized.

Share Improve this question edited Mar 12 at 10:22 sschmeck asked Mar 12 at 8:19 sschmecksschmeck 7,7536 gold badges42 silver badges77 bronze badges 1
  • 1 @sschmech Modify your /admin/host/ping route to support both GET and POST like this router.all('/admin/host/ping', (_req: Request, res: Response): void => { res.status(200).send('Healthy'); // Optional response content }); – Aslesha Kantamsetti Commented Mar 12 at 9:11
Add a comment  | 

1 Answer 1

Reset to default 0

POST method (port 80/http), which obviously responded with 404

The above error occurs because of you're using router.get, which only supports the GET method, not the POST method.

So use router.all method it supports both Get and Post method.

app.all("/admin/host/ping", (_req:  Request, res:  Response) => {
res.status(200).send("Healthy");
});

index.js:

import express, { Request, Response } from "express";
const app = express();
const PORT = process.env.PORT || 3000;
app.all("/admin/host/ping", (_req: Request, res: Response) => {
  res.status(200).send("Healthy");
});
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

Azure Output:

本文标签: Azure Web App Health endpoint implementationStack Overflow