2016-11-10 2 views
3

Azure Cloud에 Python 응용 프로그램을 배포하려고합니다. Cookiecutter template에서 웹 애플리케이션 작성 (python3.5.2x64 포함) 템플릿에서 web.config을 미리 사용하여 나는 500 오류가 발생했습니다 :
.Microsoft Azure에서 Python FastCGI 오류가 발생했습니다.

web.config 파일 :

<configuration> 
<system.web> 
    <customErrors mode="Off"/> 
</system.web> 
<appSettings> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> 
    <add key="WSGI_HANDLER" value="webapp.wsgi_app"/> 
    <add key="WSGI_LOG" value="D:\home\LogFiles\python.log"/> 
</appSettings> 
<system.webServer> 
    <httpErrors errorMode="Detailed" /> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
    <add name="Python FastCGI" 
     path="*" 
     verb="*" 
     modules="FastCgiModule"   
     scriptProcessor="D:\home\Python35\python.exe|D:\home\Python35\wfastcgi.py" 
     resourceType="Unspecified" 
     requireAccess="Script" /> 
    </handlers> 
</system.webServer> 
</configuration> 

webapp.py :

def wsgi_app(environ, start_response): 
    status = '200 OK' 
    response_headers = [('Content-type', 'text/plain')] 
    start_response(status, response_headers) 
    response_body = 'Hello World' 
    yield response_body.encode() 
if __name__ == '__main__': 
    from wsgiref.simple_server import make_server 
    httpd = make_server('localhost', 5555, wsgi_app) 
    httpd.serve_forever() 

오히려 오래된 때문에, 도움이되지 않습니다 푸른에서 장고 응용 프로그램을 사용하여 (지원되지 않는 Microsoft.Diagnostics를 사용 AttributeError: 'module' object has no attribute 'get_virtualenv_handler'을 제기).

내가 뭘 잘못하고 있는지 제안 해주세요. 고맙습니다.

업데이트. 약간의 시간을 보냈을 때 나는 파이어 폭스 (2 또는 3, 중요하지 않음)가 설치된 모든 작업이 IIS에서 보이지 않거나 제 Python Extension (Azure Portal btw에서 설치됨) . 그럼에도 불구하고 원시 Python을 사용하더라도 즉시 작동하지는 않지만 처음에는 TypeError: source code string cannot contain null bytes (Python 3.4) 또는 AttributeError: 'module' object has no attribute 'wsgi_app' (Python 2.7)을 던집니다. 그리고 약 15 분 후 마술처럼이 작동하기 시작합니다. 내가하고 있었던 모든 것이 바뀌고 있었다 Hello World! 문자열.

+0

설명서를 확인 했습니까? https://azure.microsoft.com/en-gb/documentation/articles/web-sites-python-configure/ –

+0

하지만 앱처럼 배포하거나 하늘색 가상 머신에서 배포하려고합니까? – Hackerman

+0

@Hackerman은 앱처럼, 웹 앱을 선택한 다음, 힘내 또는 VS 코드 온라인을 통해이 두 파일을 추가하고 다시 시작합니다. – pro100filipp

답변

0

아니, 솔루션은 꽤 논리적이지만 분명하지 않았습니다 (제 생각에). 방금 Azure 포털의 Web App 설정 (Web App -> Application settings -> Handler Mappings)에 핸들러를 추가했으며 모두 매력적이었습니다!

관련 문제