NOTE: For more up-to-date instructions and more explanations, please see the readme of https://github.com/jtanx/isso-azure
-
Add a new Web App
-
Go to
https://my-web-app-name.scm.azurewebsites.net
and click onSite Extensions
-
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> <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
. Stop the application from the portal, before starting again (I find that it might take more than one restart for the change to pick up) -
On the client side, modify the deployment script to use the extension Python:
npm install -g azure-cli azure config mode asm azure site deploymentscript --python
Replace everything in the
SelectPythonVersion
section indeploy.cmd
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 contents of
web.config
should be similar to below:<?xml version="1.0"?> <configuration> <appSettings> <add key="WSGI_ALT_VIRTUALENV_HANDLER" value="wsgi.application" /> <add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\activate_this.py" /> <add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_virtualenv_handler()" /> <add key="WSGI_LOG" value="D:\home\site\wwwroot\log.txt" /> <add key="PYTHONPATH" value="D:\home\site\wwwroot" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.webServer> <handlers> <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python27\python.exe|D:\home\Python27\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> </handlers> </system.webServer> </configuration>