Azure/azure-python-siteextensions

Python 3.5.2 cannot find web.config FastCGI handlers setup

YoungjaeKim opened this issue · 11 comments

As per microsoft/PTVS#1791 (comment) issue, Python 3.5.2 extension (both x86/x64) does not load web.confing FastCGI setup while 3.5.1 works fine.

Reproduce repository

Web.config

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
        <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python35\python.exe|D:\home\Python35\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
</system.webServer>

Error message

scriptProcessor could not be found in application configuration

If you're getting the error message "scriptProcessor could not be found in application configuration" it means that the fastCGI application (e.g. D:\home\Python35\python.exe) has not been declared within the applicationHost.config. The executable should be added as an in the configuration->system.webServer->fastCgi section.
When you install the extension it should copy the applicationHost.xdt transformation file to d:\home\site folder. The transformation file would then be used by the site to add necessary entries to the applicationHost.config. The content folder of the packages seem to have the xdt files (e.g. https://github.com/Azure/azure-python-siteextensions/blob/master/2712x86/content/applicationHost.xdt) but the file is not being copied during the installation of the extension.
After I addaed the file manually it solved the problem.

jtanx commented

I'm getting this problem too, using Python 2.7.12 (both x86/x64).

<handler> scriptProcessor could not be found in <fastCGI> application configuration

I tried adding both applicationHost.xdt to D:\home\site and also its contents directly to web.config (minus the xdt:Transform="InsertIfMissing"), but neither seems to help.

jtanx commented

I got it to work by:

  • Installing the IIS Manager site extension
  • Adding
    <application
       fullPath="D:\home\Python27\python.exe"
       arguments="D:\home\Python27\wfastcgi.py"
       maxInstances="16"
       idleTimeout="21600"
       instanceMaxRequests="10000000"
       signalBeforeTerminateSeconds="60">
       <environmentVariables>
         <environmentVariable name="PYTHONHOME" value="D:\home\Python27" />
       </environmentVariables>
    </application>
    Directly to applicationHost.config and clicking Save XDT then Restart Site. Setting it in applicationHost.xdt seems to do nothing. Just beware that if you screw up applicationHost.config, I think the only way to recover is to delete your whole application and start over again.
jtanx commented

Some further messing around and I got it to work via the XDT:

<?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>
</configuration>

The part that seemed to be missing was xdt:Locator="Match(fullPath)". I also had to restart the server from the portal.

zooba commented

Thanks! I'll add that to the updates I'm about to push

Thanks @zooba . When will this patch be applied? (I tested now but seems not applied yet)

zooba commented

This has only gone into the new site extensions I published the other day - 2.7.13, 3.5.3 and 3.6.1. If you're still dependent on an earlier version of Python, let me know which one and I can update that package as well.

@zooba // I tested with 3.5.2 x64 and still has the problem. so will 3.5.2 remain this issue?
I'm not using this version but I've given Flask+WebApp instruction to people many times. if the problem remains on this version, I have to give acknowledgement.

zooba commented

@YoungjaeKim I just uploaded new 3.5.2 packages with the fix, though people won't automatically update to the newer version (but they should get notified in the console if they happen to log in).

In general, the idea is to install the latest available at the time, but then to avoid having that change without warning. So since the update is going to happen anyway, I'd suggest people install 3.5.3 and take advantage of the bugfixes in that version (though that's a new package and does change paths, etc. The 3.5.2 updates do not change where Python is installed)

Hi,

I get this error for long running requests

D:\home\Python27\python.exe - The FastCGI process exceeded configured activity timeout
can someone please help with ideas
I have tried everything from above

thanks :)

zooba commented

@danielserafimovik Please create a new issue. Your problem has nothing to do with this one.