Azure / azure-python-siteextensions

Defines the Python runtime site extensions that are available for Azure App Service
Other
8 stars 9 forks source link

Python 3.5.2 cannot find web.config FastCGI handlers setup #2

Closed YoungjaeKim closed 7 years ago

YoungjaeKim commented 8 years ago

As per https://github.com/Microsoft/PTVS/issues/1791#issuecomment-258337362 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

RafalZajac commented 7 years ago

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 7 years ago

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 7 years ago

I got it to work by:

jtanx commented 7 years ago

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 7 years ago

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

YoungjaeKim commented 7 years ago

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

zooba commented 7 years ago

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.

YoungjaeKim commented 7 years ago

@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 7 years ago

@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)

danielserafimovik commented 6 years ago

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 6 years ago

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