Hi Harshit Gupta,
Lets follow few troubleshooting steps to get more clarity about the issue,
- Ensure that the Python version specified in your Azure App Service matches the version used in your GitHub Actions workflow. You can specify the Python version in the runtime.txt file in your repository.
python-3.9.7
- Ensure that the requirements.txt file is in the root directory of your repository or specify the correct path in your GitHub Actions workflow.
- Ensure that your GitHub Actions workflow installs the dependencies correctly and uses the same Python version as your Azure App Service.
- Ensure that the Azure App Service is configured to use the correct Python version. You can set this in the Azure Portal under the "Configuration" section.
- Verify that the startup command is correctly set in the Azure App Service. You can set this in the Azure Portal under the "Configuration" section, in the "General settings" tab.
gunicorn -w 4 -k uvicorn.workers.UvicornWorker app.main:app
- Check the detailed logs in the Azure App Service log stream to identify any specific issues related to the environment or missing dependencies.
- Ensure that any necessary environment variables are set correctly in the Azure App Service configuration.
Note- Check if you are calling the correct Gunicorn using which gunicorn (on Linux, or use where on Powerbash from Windows) from the terminal. If you are using a venv it should print a path pointing inside your venv directory.
Its not a good way to install using sudo apt install gunicorn
. It could be a good option for your production container, where you'll probably run the application without a venv, but in developer mode on you machine it will work better if you install gunicorn inside your venv directory using the pip install gunicorn
, using the pip
from your venv.
Then you can call it with python -m gunicorn main:app -k uvicorn.workers.UvicornWorker
If you have any further assistant, do let me know.
If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.