-
Create a new web app (click here for shortcut to location in portal)
-
Once created, go to
your-app-name.scm.azurewebsites.net
(the Kudu interface) -
Install the
Python 2.7.12 x64
andIIS Manager
extensions. Click onRestart site
when both are installed. -
Under the installed site extensions, click on the play (▶) button for
IIS Manager
. -
Go to the
applicationHost.xdt
tab -
Enter the following contents:
<?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.webServer> <rewrite> <allowedServerVariables> <add name="HTTP_X_FORWARDED_FOR" xdt:Transform="InsertIfMissing"/> </allowedServerVariables> </rewrite> <fastCgi> <application fullPath="D:\home\Python27\python.exe" arguments="D:\home\Python27\wfastcgi.py" maxInstances="16" idleTimeout="21600" instanceMaxRequests="10000000" signalBeforeTerminateSeconds="60" xdt:Transform="InsertIfMissing" xdt:Locator="Match(fullPath)"> <environmentVariables> <environmentVariable name="PYTHONHOME" value="D:\home\Python27" /> </environmentVariables> </application> </fastCgi> </system.webServer> <location path="%XDT_SITENAME%" xdt:Transform="InsertIfMissing" xdt:Locator="Match(path)"> <system.webServer xdt:Transform="InsertIfMissing"> <applicationInitialization xdt:Transform="InsertIfMissing"> <add initializationPage="/" xdt:Transform="InsertIfMissing"/> </applicationInitialization> <rewrite xdt:Transform="InsertIfMissing"> <rules xdt:Transform="InsertIfMissing"> <rule name="Force HTTPS" enabled="true" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <conditions> <add input="{HTTPS}" pattern="off" /> <add input="{WARMUP_REQUEST}" pattern="1" negate="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </location> </configuration>
You may omit the
<location>
block if you wish, but this forces HTTPS. -
Click on
Save XDT
, then onRestart site
. -
Go back to Kudu and go to
Debug console->CMD
-
Upgrade pip and install virtualenv:
D:\home\Python27\python -m pip install --upgrade pip D:\home\Python27\python -m pip install virtualenv
-
Back in the Azure portal, go to
Deployment options
->Configure required settings
and selectLocal Git Repository
. Click Ok. -
Modify
production.cfg
to configure Isso to suit your needs. -
Push this repository using the provided git details from the portal.
-
As is, Isso does not require any of its dependencies to be compiled, as they all provide the necessary wheels. If any Python packages require compilation, you must compile it yourself and make the wheels. Install Microsoft Visual C++ Compiler for Python 2.7 and use the provided console to compile the required packages with
pip wheel your-package
. Dump the wheels in a folder calledwheelhouse
and add--find-links=wheelhouse
torequirements.txt
. -
We use the Python provided by the extension as the pre-installed version runs a 32-bit version of Python 2.7.8. If you really want to, you can make use of this instead of the extension. However, to do so, you will have to build the
misaka
wheel yourself using a version ofpip wheel
that is compatible with the server. From past experience, version 0.24.0 ofpip wheel
should work. You may also need to downgradepip
to match that on the server. -
A custom Python deployment script is also used. This is necessary as the original deployment script assumes the use of the system/preinstalled Python. This was made by running:
npm install -g azure-cli azure config mode asm azure site deploymentscript --python
This generates the
.deployment
anddeploy.cmd
files. Indeploy.cmd
, replace everything in theSelectPythonVersion
with::SelectPythonVersion SET PYTHON_RUNTIME=python-2.7 SET PYTHON_VER=2.7 SET PYTHON_EXE=%SYSTEMDRIVE%\home\python27\python.exe SET PYTHON_ENV_MODULE=virtualenv
The goal is to replace
D:\Python27
withD:\home\Python27
-
The modification to
applicationHost.xdt
(which should reside inD:\home\site
) is necessary so that IIS knows how to handle Python requests using the extension version that we installed. See here for more information. -
The (half-baked) blog post by MS on upgrading Python suggests to install Python modules directly and without the use of a virtualenv. I strongly disagree with this. If any of the packages break for whatever reason, it's much easier to just wipe the
env
folder and rebuild the virtualenv than it is to remove the packages from the installed Python. -
HTTP_X_FORWARDED_FOR
needs to be set, otherwise theremote_addr
that Isso gets will be0.0.0.0
.