gpt4 book ai didi

azure - 如何在 Azure 应用服务上部署 FastAPI

转载 作者:行者123 更新时间:2023-12-03 04:40:29 26 4
gpt4 key购买 nike

我想将一个简单的 FastAPI 部署到 Azure 应用服务上,但我不断收到此错误消息。

enter image description here

这是我的 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

我已经设置了应用服务的配置:

enter image description here

定价等级为:

enter image description here

我在管道中没有看到任何问题:

enter image description here

或者,我尝试了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.

更多信息请点击:Using FastAPI Framework with Azure Functions

关于azure - 如何在 Azure 应用服务上部署 FastAPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74343574/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com