Reputation: 7198
I am trying to host my python api on azure web app. It is a Flaks based application and having a demo flask code . I have created resource group and setup everything. But when accessing the url it shows
although I can see from the deployment options, it has successfully deployed my bitbucket project. I have selected python3.4 version in the application settings. I have tried adding the latest python extension but only 3.6version is available. I have added the python3.6 extension but it still only show python3.4 in application settings.
I do not know how can I resolve this issue. Please help. Thanks.
Upvotes: 1
Views: 1182
Reputation: 23782
S Andrew.
web.config
file is essential in the deployment of your web App.You could create the web.config file on the KUDU url.
You could navigate to KUDU via below two way:
1.Find the button on the portal.
2.access url directly: https://.scm.azurewebsites.net/
On the KUDU,you could see your app structure in the path: D:\home\site\wwwroot
,you need to create web.config
file here.
Also,you could see your python extension in the path:D:\home\
, if you want to use extension environment, you need to configure the correct path in web.config
.
Please see my sample web.config
file.Related to web.config
, you could refer to this official doc.
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="<your app 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>
More details about python app deployment on the azure,please see my previous cases,you will find the answer.
1.Failed to Deploy Flask to Azure
2.deploying python flask project on azure using visual Studio
Hope it helps you.
Upvotes: 2
Reputation: 41
You have to make a webconfig file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_HANDLER" value="main.app"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python364x86\python.exe|D:\home\Python364x86\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
Make sure to change the value of main.app to whatever your file name is and to change the path for python to your path. This solved the issue for me.
Upvotes: 1