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.
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 |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.
1 Answer
Reset to default 0
POST
method (port 80/http), which obviously responded with404
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
版权声明:本文标题:Azure Web App Health endpoint implementation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744764598a2623962.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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