I've got a challenge with deploying Django app (wagtail to be precise) to Azure Web Services using external Git repo (Bitbucket). I want to use Python 3.6.1, therefore I followed instructions at Managing Python on Azure App Service manual
- I have python 3.6.1 extension installed and in place
- I created web.config file in root directory of my app (I checked and it is uploaded to the server)
However, deploy fails with message
Detecting Python runtime from runtime.txt
Unsupported runtime: python-3.6.1
Supported runtime values are:
python-2.7
python-3.4
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\66.61008.3066\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
My web.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<!-- Django apps only -->
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()"/>
<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>
Paths are ok, below is ls
from Kudu console
D:\home\python361x64>ls
DLLs
Lib
Scripts
__pycache__
python.exe
python3.dll
python36.dll
pythonw.exe
sitecustomize.py
vcruntime140.dll
wfastcgi.py
It looks like the deployment process is not taking into account the web.config file that I have, or the python version that I've installed via extensions is not visible.
Could you please tell me where the possible issue could be?
Best regards,
Konrad
I am posting the missing parts of Calfy answer.
app.wsgi_app is actually app.py in your folder and from what i understand it must be an wsgi app not regular python app.. (i also used cherrypy mod here) this sample app is copied somewhere from internet.
I tried to reproduce your issue but failed.I tried to deploy my own
django web app
to azure and it works.You could refer to my steps and check if you you missed something.
Step 1: Follow the official tutorial to create your azure web app.
Step 2: Add Python extension.
Step 3: Add
web.config
file and deploy your web app.Step 4: Install
pip plugin
in yourpython extension environment
.Step 5: Install
django
module and other modules you want to use.There are some similar SO threads you could refer to.
Hope it helps you.
After a couple of hours of fighting, I finally managed to run this bastard as expected ;)
Thanks, @Jay Gong for your input as going step by step with this tutorial showed me a couple of things.
runtime.txt
file, which I had in the root folder, was the first issue. As 3.6 version of python is installed via extensions, in fact, deployment process does not now that this v. exists (it "knows" only 2.7 and 3.4). So the first step was to get rid of this file.When
runtime.txt
had been removed, deployment process has been using python 3.4 and was failing on installation one of the dependencies fromrequirements.txt
file (probably because of the older version of python). So the next step was to add .skipPythonDeployment, to avoid automatic installation of requirements and install those manually by kudu console. In folder with our python env (in my caseD:\home\python361x64
) following command was launchedpython.exe -m pip install --upgrade -r D:\home\site\wwwroot\requirements.txt
All dependencies were installed correctly.
After deploy, launching an app in a web browser showed message
The page cannot be displayed because an internal server error has occurred.
. Next step was to gather more info about the issue, so I have added a few new lines inweb.config
file:Thanks to that, I was able to check what is causing the issue. In my case, it was a
WSGI_HANDLER
value inweb.config
. I set it to a correct value (for wagtail it was<app_name>.wsgi.application
and then it started working.Thank you guys for all your support.