I have been trying to deploy a website to Azure with App services. I have used a requirements.txt file to install flask and wfastcgi and other needed dependencies also I am using Python 3.6. I have setup the web.config file to properly start python and utilize wfastcgi package as well. When i try to navigate to the site i get a wfastcgi error like this.
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 551, in get_wsgi_handler
raise ValueError('"%s" could not be imported' % handler_name)
ValueError: "D:\home\site\wwwroot\FlaskTest.app" could not be imported
My files are stored in the "D:\home\site\wwwroot" It is structured like so
D:\home\site\wwwroot
|FlaskTest.py
|web.config
|requirements.txt
My FlaskTest.py is just the simple quickstart Flask app.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello from FastCGI via IIS!"
if __name__ == '__main__':
app.run()
And here is my Web.config:
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
scriptProcessor="D:\Python34\python.exe|D:\Python34\scripts\wfastcgi.py"
resourceType="Unspecified" requireAccess="Script"/>
</handlers>
<httpErrors errorMode="Detailed" />
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="WSGI_HANDLER" value="D:\home\site\wwwroot\FlaskTest.app" />
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
</configuration>
I'm really not sure what is wrong with the WSGI_HANDLER key. From everything I have read this should work. I have tried adding a init.py to the directory and I still receive the error. For some reason I can understand Wfastcgi is having trouble importing the "app" object as that is what I have the Flask object named as. Any light that can be shed on this would be much appreciated as I have been bashing my head on it for days now.
Copied from the comment.
Microsoft deprecated Python on Azure App Service on Windows (along with the underlying components such as wfastcgi),
Therefore, the only feasible way of hosting Python apps today is to use App Service on Linux.