'Azure Application Gateway received invalid status code: 404 from App Service

I am using Microsoft Learn to setup the following lab: https://docs.microsoft.com/en-us/learn/modules/load-balance-web-traffic-with-application-gateway/5-exercise-create-configure-application-gateway.

However, I can´t get it working as described as my app service always shows unhealthy due to:

Received invalid status code: 404 in the backend server’s HTTP response. As per the health probe configuration, 200-399 is the acceptable status code. Either modify probe configuration or resolve backend issues. To learn more visit - https://aka.ms/StatusCodeMismatch.

I am wondering if this is a bug as the App Service is reachable http/https. I don´t know how the probe is made to path '/' but if it using http://app-service-default-name.azurewebservices.net/:80 that will fail. Could this be the reason or am I doing something wrong?

Best, Mario



Solution 1:[1]

Ok after various time of troubleshooting I was able to fix it myself by setting Override with new host name of the http settings to yes and then use Pick host name from backend target. Maybe that helps anyone else with that problem. For the CLI its the parameter --host-name-from-backend-pool I believe. Seems its missing in the exercise. But since I am using Terraform anyways I just had to update the backend_http_settings block with pick_host_name_from_backend_address and set the probe_name.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 magichappens