Azure Web App Health endpoint implementation - Stack Overflow

I setup an Azure Web App using express.js with TypeScript. It implements a health check endpoint. The a

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:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744764598a4592382.html

相关推荐

  • Azure Web App Health endpoint implementation - Stack Overflow

    I setup an Azure Web App using express.js with TypeScript. It implements a health check endpoint. The a

    17小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信