I've been digging into a problem where my Azure Web App container refuses to start, even though the logs indicate that my app is listening properly. I also ran into an 'Error routing requests to application container' during slot swaps. Here's how I managed to fix it:
1. **Port Mapping:** I realized Azure requires the container to use port 80. So, I set the `WEBSITES_PORT` to 80 and adjusted `ASPNETCORE_URLS` to http://0.0.0.0:80.
2. **Startup Timeout:** The app needed more time to initialize Redis, so I increased the `WEBSITES_CONTAINER_START_LIMIT` to 400 seconds.
3. **Health Check:** To prevent some redirect loops during the warmup phase, I changed the health check from `/health` to `/`.
4. **Slot Warmup:** I also deleted the `WEBSITE_SWAP_WARMUP_PING_STATUSES` which solved the deployment slot failures.
Has anyone experienced similar issues with Azure App Service containers? If anyone's interested, I've documented the entire troubleshooting process along with logs on my blog.
3 Answers
The logs are your best friend here! I figured out my problem when I saw the message indicating what port the app was listening on. It turned out there was a mismatch because the Dockerfile exposed port 8000, while .NET 6 was set to listen on port 80. Once we synced those up, everything clicked into place. Definitely check your logs for clues!
Totally feel you on the port mismatch issue! It's so common for people to get tripped up by the fact that Azure expects a service to listen on port 80. I've been there and had to adjust the `WEBSITES_PORT` a few times myself. Also, bumping the startup timeout is key when you're dealing with Redis or databases making that cold start. They can really add a few minutes to the initialization time.
Another tip is to ensure that any environment variables you set up for your container stay consistent after each deployment. I had issues with mine reverting back which caused the startup failures. Adjusting the settings in the configuration files helped me avoid those pitfalls.

Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux