无法将Flask部署到Azure

编程入门 行业动态 更新时间:2024-10-21 15:57:25
本文介绍了无法将Flask部署到Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将 python flask 部署到 azure ,但是无法通过.我在 Azure

上创建了一个api服务

这是我的 api 的 url ,它与 python 3

第2步:发布您的 flask 项目并添加 web.config .

web.config:

<?xml version ="1.0" encoding ="utf-8"?><配置>< appSettings><添加key ="WSGI_HANDLER" value =<您的项目名称> .app"/><添加key ="PYTHONPATH" value ="D:\ home \ site \ wwwroot"/><添加key ="WSGI_LOG" value ="D:\ home \ LogFiles \ wfastcgi.log"/></appSettings>< system.webServer><处理程序><添加名称="PythonHandler" path ="*"动词="*" modules ="FastCgiModule" scriptProcessor ="D:\ home \ Python361x64 \ python.exe | D:\ home \ Python361x64 \ wfastcgi.py" resourceType =未指定" requireAccess ="Script"/></handlers></system.webServer></configuration>

第3步:切换到Kudu CMD并命令 cd Python361x64 和 touch get-pip.py 并复制URL的内容 通过编辑"按钮将bootstrap.pypa.io/get-pip.py 放入 get-pip.py ,然后运行 python get-pip.py 进行安装点子工具.

第4步:通过 python -m pip install pyodbc

安装所需的任何软件包

希望它对您有帮助.如有任何疑问,请告诉我.

I'm trying to deploy python flask to azure but can not get it through. I create a api service on Azure

Here is the url for my api, and it serves with python 3 textclassifier.azurewebsites/

then I created a default flask project on visual studio, without changing any code, I click publish directly. Chosen the the app service I created from portal, publishing shows successfully in VS Output:

Adding file (TextClassifier\TestFlask__init__.py). Adding ACLs for path (TextClassifier) Adding ACLs for path (TextClassifier) Publish Succeeded. Web App was published successfully textclassifier.azurewebsites/ ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ========== ========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

However, when I access url textclassifier.azurewebsites/home browers shows : " The resource you are looking for has been removed, had its name changed, or is temporarily unavailable".

I checked that /home is routed to a controller

Can anyone help me out, I have been stuck for days.

解决方案

Per my experience, your issue is resulted from the azure app python environment. Please refer to my work steps and see if the error still shows up.

As you found in the Managing Python on Azure App Service , Azure App Service provide you with a site extension. You could install packages on KUDU console.

Step 1 : Create azure web app and add Extensions(here is Python 3.6.1 x64)

Step 2 : Publish your flask project and add the web.config.

web.config:

<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="WSGI_HANDLER" value="<Your Project Name>.app"/> <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> </appSettings> <system.webServer> <handlers> <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> </handlers> </system.webServer> </configuration>

Step 3: Switch to the Kudu CMD and commands cd Python361x64 and touch get-pip.py and copy the content of the url bootstrap.pypa.io/get-pip.py into the get-pip.py via Edit button, then run python get-pip.py to install the pip tool.

Step 4 : Install any packages you need via python -m pip install pyodbc

Hope it helps you. Any concern ,please let me know.

更多推荐

无法将Flask部署到Azure

本文发布于:2023-11-25 23:59:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Flask   Azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!