1

I want to deploy a simple FastAPI onto an Azure app service, but I keep getting this error message.

enter image description here

This is my api.

from fastapi import FastAPI

app = FastAPI()

@app.get('/')
async def welcome():
    return {'message':'Wecome to My website!'}

The api works just fine on my local machine. The command I use on my VS code terminal is "uvicorn main: app".

In order to deploy my app, I have startup.sh where there is only one command line:

gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app

I've set up the configuration of the app service:

enter image description here

The pricing tier is :

enter image description here

I don't see any probem in the pipeline:

enter image description here

Alernatively, I've tried with each of following lines of code in startup.sh:

python -m uvicorn main:app
gunicorn --bind=0.0.0.0 --timeout:600 main:app

But all failed. Help is much appreciated!

chutzpah
  • 31
  • 3
  • 1
    Does this answer your question? [ModuleNotFoundError while importing python files as modules in Azure App Services](https://stackoverflow.com/questions/73603297/modulenotfounderror-while-importing-python-files-as-modules-in-azure-app-service) – Chris Nov 07 '22 at 09:06
  • 1
    Can you access any logs? What if you click the diagnostic resources link? – M.O. Nov 07 '22 at 17:49
  • 1
    How you are deploying your App ? – Harshitha Nov 08 '22 at 09:45
  • Not all the comments above helped, but many thanks. I've figured it out at last. Nothing wrong about my code and pipeline. The problem was the web app service plan. With such such a free plan, there are not many things to do. Just upgrading the plan solved everything. – chutzpah Nov 09 '22 at 09:22

1 Answers1

-1

There are three main ways to deploy this to Azure:

  • Deploy with the VS Code Azure Functions extension.
  • Deploy with the Azure CLI.
  • Deploy with the Azure Developer CLI: After installing the azd tool, run azd up in the root of the project. You can also run azd pipeline config to set up a CI/CD pipeline for deployment.

More info here: Using FastAPI Framework with Azure Functions

genegc
  • 1,630
  • 18
  • 16