简体   繁体   English

Azure 应用服务在嵌套文件夹中找不到 flask 应用。 即使有 GUnicorn

[英]Azure App Service Can't find flask app in nested folder. Even with GUnicorn

I have a flask app which I'm able to run locally no problem, the issue is when I try to run it in Azure, it seems the app.py can't be found since I'm deploying with GitHub. My file tree looks something like below, and Azure starts in the /Chatbot folder.我有一个 flask 应用程序,我可以在本地运行没问题,问题是当我尝试在 Azure 中运行它时,似乎找不到 app.py,因为我正在使用 GitHub 进行部署。我的文件树如下所示,Azure 在 /Chatbot 文件夹中开始。 I need to get into /Chatbot_Application/Chatbot to access app.py我需要进入 /Chatbot_Application/Chatbot 才能访问 app.py

Chatbot 
├─── .vs
├───Chatbot_Application
│   └───Chatbot
│       ├───chatbot_backend
|       ├───app.py
|   ├─gunicorn.conf.py 

If I run the Azure app like this I get no code output, IF I adjust the start up configuration to this如果我像这样运行 Azure 应用程序,如果我将启动配置调整为此,则不会得到代码 output

gunicorn --bind=0.0.0.0 --chdir /Chatbot_Application.Chatbot app:app

I get an error "can't chdir to 'Chatbot_Application.Chatbot'" no matter what format I put.无论我输入什么格式,我都会收到错误消息“无法 chdir 到‘Chatbot_Application.Chatbot’”。 I'm thinking of going the wsgi.py route but I don't think I'll get any luck because it won't be able to import the app.py modules.我正在考虑走 wsgi.py 路线,但我认为我不会有任何好运,因为它无法导入 app.py 模块。

So, the solution was using this format for the startup command.因此,解决方案是将这种格式用于启动命令。

gunicorn --bind=0.0.0.0 Chatbot_Application.Chatbot.app:app 

This will help Azure recognize the app.py, keep in mind the module within my app.py is called app so that's why it's app:app.这将帮助 Azure 识别 app.py,请记住我的 app.py 中的模块称为 app,这就是为什么它是 app:app。 You'll have to solve the issue 'cannot find module'你必须解决“找不到模块”的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM