Hi Shubhankar Khandai,
Welcome to the Microsoft Q&A Platform!
It seems that the issue is related to Azure's default behavior for containerized applications. By default, Azure Web App containers ping the application on port 8000.
Check Azure Port Configuration Azure Web App expects the application to run on the port defined by the environment variable PORT
. Even though you set WEBSITES_PORT=443
, the default behavior requires you to use PORT
instead.
Update your Flask application to dynamically use the PORT
environment variable
import os
if __name__ == "__main__":
port = int(os.environ.get("PORT", 443)) # Fallback to 443 if PORT is not set
application.run(debug=True, host="0.0.0.0", port=port)
- Set the
PORT
Environment Variable in Azure In the Azure Web App settings - Go to Configuration > Application Settings.
- Add a new key
PORT
with the value443
. - Adjust Your Deployment Configuration If you are using a Docker container:
- Ensure the Dockerfile or the startup command maps the correct port.
EXPOSE 443
CMD ["gunicorn", "-b", "0.0.0.0:443", "app:application"]
If not using Docker:
- Ensure your GitHub Actions workflow or deployment script is not overriding the port.
- Verify Logs After redeploying.
- Check the logs in Azure's Log Stream to confirm the application is listening on the correct port.
- Ensure no errors indicate a mismatch in the expected and actual ports.
- Network Considerations for HTTPS (Port 443) If you're using port 443, remember that HTTPS traffic is typically terminated by Azure's built-in SSL endpoint, and the traffic is forwarded to your app on the
PORT
environment variable. Ensure no SSL configuration conflicts exist.
If the answer is helpful, please click "Accept Answer" and kindly upvote it.