I built and deployed Flask app in Python to Azure. I tested the app locally and everything works. I am using Kudu for deployment on Windows and Python 3.6.
However, once the app is successfully deployed, all I can see is the default page:
This website is running Python 3.6.6
From what i saw, the fault is on the Kudu web.config
file, which looks like this:
<configuration>
<appSettings>
<add key="pythonpath" value="%SystemDrive%\home\site\wwwroot" />
<add key="WSGI_HANDLER" value="hostingstart-python.application" />
</appSettings>
</configuration>
For some reason, it points to the hostingstart-python.application
(has .html
and .py
files) which indeed shows the default page.
My /wwwroot
folder looks as follows:
env
templates
.gitignore
app.py
config.py
file_manager.py
hostingstart-python.html
hostingstart-python.py
README.md
requirements.txt
web.config
I tried various versions of the web.config
file, such as the one below, but without any luck.
For WSGI_HANDLER
I put name of the web app, but perhaps another name has to be there?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="UploadToolApp.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/scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
Which results in:
The page cannot be displayed because an internal server error has occurred.
The solution was to switch to Linux machine, then everything works as it supposed to.