我想将一个简单的 FastAPI 部署到 Azure 应用服务上,但我不断收到此错误消息。
这是我的 API。
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
async def welcome():
return {'message':'Wecome to My website!'}
该 API 在我的本地计算机上运行良好。我在 VS code 终端上使用的命令是“uvicorn main: app”。
为了部署我的应用程序,我有startup.sh,其中只有一个命令行:
gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app
我已经设置了应用服务的配置:
定价等级为:
我在管道中没有看到任何问题:
或者,我尝试了startup.sh中的以下每一行代码:
python -m uvicorn main:app
gunicorn --bind=0.0.0.0 --timeout:600 main:app
但是都失败了。非常感谢您的帮助!
最佳答案
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.
关于azure - 如何在 Azure 应用服务上部署 FastAPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74343574/