deploying python flask project on azure using visual Studio

ぐ巨炮叔叔 提交于 2019-12-11 17:47:38

问题


I am having some trouble getting my Py project to be deployed on Azure. The message I get is "The page cannot be displayed because an internal server error has occurred."

Which I know is a config error in the project. My web.config file has the below.

Python is installed in D in my azure web service and in C in my local machine running Py2.7

Appname is whiteboard

port 5965 on local host...

What am I doing wrong?? MS documentation did not help

<configuration>
    <appSettings>
    <add key="WSGI_HANDLER" value="whiteboard.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\Python27\python.exe|D:\home\Python27\wfastcgi.py"
        resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
    <httpPlatform processPath="C:\Python27\python.exe"
    arguments="F:\FYP-Whiteboard\Whiteboard\whiteboard\runserver.py %HTTP_PLATFORM_PORT%5"
    stdoutLogEnabled="true"
    stdoutLogFile="F:\FYP-Whiteboard\Whiteboard\whiteboard\LogFiles\python.log"
    startupTimeLimit="60"
    processesPerApplication="16">
    <environmentVariables>
        <environmentVariable name="SERVER_PORT" value="5965" />
        <environmentVariable name="PYTHONPATH" value="D:\home\site\wwwroot" />
        <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
    </environmentVariables>
    </httpPlatform>
    </system.webServer>
    </configuration>

回答1:


Per my experience, your issue is resulted from the package missing or route error in web.config.(Or you could find log in wfastcgi.log) I did test successfully, please refer to my working steps:

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.4 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\Python364x64\python.exe|D:\home\Python364x64\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 https://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 Flask

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



来源:https://stackoverflow.com/questions/51507268/deploying-python-flask-project-on-azure-using-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!