Hello @Amogh Joshi !
Welcome to Microsoft QnA!
As we read from https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux&tabs=debian
Configure port number
By default, App Service assumes your custom container is listening on port 80. If your container listens to a different port, set the WEBSITES_PORT
app setting in your App Service app. You can set it via the Cloud Shell. In Bash:
Azure CLI
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000
In PowerShell:
Azure PowerShell
Set-AzWebApp -ResourceGroupName <group-name> -Name <app-name> -AppSettings @{"WEBSITES_PORT"="8000"}
When deploying applications on Azure App Service, port binding is handled by Azure automatically. Azure App Service expects your application to listen on port 80 for HTTP requests or 443 for HTTPS, and it maps the incoming requests to that port inside the container.
However, if you need to use a different port, you should be able to specify it in the Dockerfile or the application settings in Azure portal and use it with the WEBSITES_PORT app setting.
Update the Dockerfile. If you're using something like EXPOSE 8080
, you would change this line to the port you wish to use, e.g., EXPOSE 8000
.
Update the Azure app setting. Navigate to the Azure portal, go to your App Service, and then go to Configuration > Application settings. Add a new setting with the name WEBSITES_PORT
and the value being the port you wish to use, e.g., 8000
.
It's important to note that this won't change the port that clients use to access your application, which will still be 80/443, but it will change the port that your application listens on within its container. This might be required if you're using a custom image that expects to listen on a specific port.
Regarding your startup.txt
file, since you're using Docker, the application startup command should be defined in the Dockerfile CMD
or ENTRYPOINT
instruction rather than a startup.txt
file. The startup.txt
file is usually used when deploying code directly without a Docker container.
You also mentioned you're using gunicorn, you can specify the port using something like this in your Dockerfile:
dockerfile
CMD ["gunicorn", "-b", ":8000", "myapp:app"]
Remember to replace myapp:app
with the actual WSGI application you're trying to run.
I hope this helps!
Kindly mark the answer as Accepted and Upvote in case it helped!
Regards