Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Application Insights fills with 404 requests nobody sent to the API

Your error

"GET /robots933456.txt HTTP/1.1" 404

Fix it fast

Most common cause, 1 of 3

Always On calls the root path, and the API has no route there

Add a cheap GET / route that returns 200.

Fix
// ASP.NET Core minimal API
app.MapGet("/", () => "OK");

// Express
app.get('/', (req, res) => res.send('OK'));

# or turn Always On off
az webapp config set -g MyResourceGroup -n MyWebapp --always-on false
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Regular 404s in Application Insights for an Azure App Service API are usually platform pings. Always On sends GET / every five minutes, Health check calls its path every minute, and Linux containers get a /robots933456.txt probe. Add a 200 route at / or a real health path, and ignore the robots probe. Applies to Windows and Linux plans.

  • Applies to Azure App Service (Windows and Linux plans), Application Insights, workspace-based (AppRequests table), Azure CLI az webapp config
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

In the Application Insights Logs view, group the 404s by path and look at their timing. A path that repeats at a fixed interval with no real user behind it is a platform ping; the path and the interval tell you which one.

Run this first
AppRequests
| where TimeGenerated > ago(1d) and ResultCode == "404"
| summarize hits = count(), first = min(TimeGenerated), last = max(TimeGenerated) by Name, Url
| order by hits desc

Then find the line you see in this list and open its fix:

  1. 1Always On calls the root path, and the API has no route thereThe failing request is GET / and it repeats about every five minutes, also at night
  2. 2Health check points at a path the app does not haveThe 404 path is the one set under Monitoring > Health check, it repeats every minute, and instances drop out of rotation or get replaced
  3. 3The Linux container start probe for /robots933456.txtThe path is /robots933456.txt and the entries appear around restarts, deployments or scale-out

What does the error look like?

  • "GET /robots933456.txt HTTP/1.1" 404

Cause 1 of 3

Always On calls the root path, and the API has no route there

You seeThe failing request is GET / and it repeats about every five minutes, also at night

Check

Steady 404s for GET / on an App Service API come from Always On when nothing in the app answers the root URL. With Always On turned on, the front-end load balancer sends a GET request to the application root every five minutes to keep the app loaded, and an API that only maps /api/... routes replies 404 to each one.

Check
az webapp config show --name MyWebapp --resource-group MyResourceGroup | grep -i alwayson

Fix

Add a cheap GET / route that returns 200. If the app does not need to stay warm and runs no continuous or scheduled WebJobs, you can turn Always On off instead, at the cost of a slow first request after 20 idle minutes.

Fix
// ASP.NET Core minimal API
app.MapGet("/", () => "OK");

// Express
app.get('/', (req, res) => res.send('OK'));

# or turn Always On off
az webapp config set -g MyResourceGroup -n MyWebapp --always-on false

Verify

After the next deployment the five-minute GET / entries show result code 200.

Verify
AppRequests
| where TimeGenerated > ago(1h) and Url endswith "/"
| summarize count() by ResultCode

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

Health check points at a path the app does not have

You seeThe 404 path is the one set under Monitoring > Health check, it repeats every minute, and instances drop out of rotation or get replaced

Check

When the Health check path is a route the app does not serve, every probe returns 404. App Service has no default path: it pings the one you entered on every instance at one-minute intervals, and an instance that keeps answering outside 200-299 is taken out of the load balancer and later replaced. The 404s are then a real outage risk, not only noise.

Check
AppRequests
| where TimeGenerated > ago(1h) and ResultCode == "404"
| summarize count() by Name, bin(TimeGenerated, 1m)

Fix

Create the endpoint at the configured path, or change the setting to a path that exists. It should return 200 only once the app is warmed up and can reach its critical dependencies, and it must allow anonymous access if the app uses its own authentication.

Fix
// ASP.NET Core minimal API
app.MapGet("/api/health", () => "Healthy");

// Express
app.get('/api/health', (req, res) => res.send('Healthy'));

Verify

The Health check page shows the instances as healthy and the one-minute 404s stop.

Verify
curl -i https://myapp.azurewebsites.net/api/health

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

The Linux container start probe for /robots933456.txt

You seeThe path is /robots933456.txt and the entries appear around restarts, deployments or scale-out

Check

A 404 for /robots933456.txt on a Linux App Service is expected. Microsoft documents it as a dummy path App Service requests to see whether the container can serve HTTP; the 404 itself tells App Service the container is up and ready.

Check
AppRequests
| where TimeGenerated > ago(7d) and Url has "robots933456"
| summarize count() by bin(TimeGenerated, 1h)

Fix

Do not add a route for it. Leave the path out of failed-request alerts and dashboards so real 404s stay visible.

Fix
AppRequests
| where ResultCode == "404" and Url !has "robots933456"

Verify

Your 404 alert no longer fires after a restart, while a test request to a wrong URL still shows up.

Verify
curl -i https://myapp.azurewebsites.net/does-not-exist

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Give every App Service API a GET / route and a separate health route from the first deployment, and test both in CI with curl.
  • Write failed-request alerts on AppRequests that exclude the known probe paths instead of alerting on the raw 404 count.
  • Record the Always On and Health check settings in your infrastructure code so a portal change does not silently start new pings.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Raheeb.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.