2017-08-27 3 views
1

Ich habe eine einfache App mit Django in Visual Studio 2017, die Verwendung der Standardvorlage in Visual Studio (Datei - Neu - Projekt - Python - Django Webanwendung). Ich habe Django PTVS über das Azure-Portal installiert und eine benutzerdefinierte Python-Erweiterung hinzugefügt. Die App läuft richtig lokal, aber nachdem ich es implementieren über Visual Studio Azure, kann ich nur auf die Seite zugreifen, die zeigt:Bereitstellen von Django App auf Azure VS2017 - benutzerdefinierte Python

'Your App Service app has been created.'

ich mehrere Beiträge (Deploy a simple VS2017 Django app to Azure - server error) und folgte den folgenden Tutorials gelesen haben: https://docs.microsoft.com/en-us/visualstudio/python/managing-python-on-azure-app-service

Meine web.config sieht wie folgt aus:

<?xml version="1.0"?> 
<configuration> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
     <remove name="Python27_via_FastCGI" /> 
     <remove name="Python34_via_FastCGI" /> 
     <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python361x64\python.exe|D:\home\python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> 
    </handlers> 
    </system.webServer> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <appSettings> 
    <add key="PYTHONPATH" value="%SystemDrive%\home\site\wwwroot" /> 
    <add key="WSGI_HANDLER" value="DjangoWebProject2.wsgi.application()"/> 
    <add key="DJANGO_SETTINGS_MODULE" value="app.settings" /> 
    </appSettings> 
</configuration> 

UPDATE:

Ich schaffte es, es zum Laufen zu bringen, das Problem war, dass es immer noch das env mit Python 3.4 verwendete und es schien eine Paketabhängigkeit zu geben, die eine neuere Version von Python benötigte. Daher änderte ich die App-Einstellungen wie folgt.

<configuration> 
    <appSettings> 
    <add key="WSGI_HANDLER" value="myApp.wsgi.application"/> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> 
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot" /> 
    <add key="DJANGO_SETTINGS_MODULE" value="myApp.settings" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
     <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python362x86\python.exe|D:\home\python362x86\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="Static Files" stopProcessing="true"> 
      <conditions> 
      <add input="true" pattern="false" /> 
      </conditions> 
     </rule> 
     <rule name="Configure Python" stopProcessing="true"> 
      <match url="(.*)" ignoreCase="false" /> 
      <conditions> 
      <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
+0

Hallo, irgendwelche Updates? –

+0

@JayGong Entschuldigung, ich dachte, ich hätte bereits die Ergebnisse gepostet. Also ja, ich schaffte es, es zum Laufen zu bringen, das Problem schien zu sein, dass es das env mit Python 3.4 weiter verwendete. Ich habe daher die App-Einstellungen geändert, um eine neuere Python-Version zu verwenden. – Galdar

+0

Ok. Vielen Dank für Ihre Antwort. Ich habe das Problem in meiner Antwort zusammengefasst. Sie können die Antwort für die Referenz von anderen im Forum markieren. –

Antwort

0

Ich habe versucht, das Problem zu reproduzieren, scheiterte aber. Meine Django App erstellt & von VS2017 zu Azure WebApps bereitgestellt und es funktioniert. Es gibt einige ähnliche SO-Threads, die das gleiche Problem mit Ihrem haben.

  1. Only getting Your App Service app has been created - after deploying to azure
  2. Django web app deploy in Azure via Visual Studio 2017

Sie können die obigen Themen folgen noch einmal zu versuchen. Sie können auch auf the official tutorial for Django verweisen, um Ihre django-App in Azure zu erstellen und bereitzustellen, und dann Ihre web.config ändern, um die Erweiterung Python 3.6.1 zu verwenden.

Hier ist der Inhalt meiner web.config Datei wie folgt.

<?xml version="1.0"?> 
<!-- Generated web.config for Microsoft Azure. Remove this comment to prevent 
    modifications being overwritten when publishing the project. 
--> 
<configuration> 
    <system.diagnostics> 
    <trace> 
     <listeners> 
     <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> 
      <filter type="" /> 
     </add> 
     </listeners> 
    </trace> 
    </system.diagnostics> 
    <appSettings> 
    <add key="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_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="PYTHONPATH" value="D:\home\site\wwwroot" /> 
    <add key="DJANGO_SETTINGS_MODULE" value="JayGongDjango.settings" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
     <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python361x64\python.exe|D:\home\python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="Static Files" stopProcessing="true"> 
      <conditions> 
      <add input="true" pattern="false" /> 
      </conditions> 
     </rule> 
     <rule name="Configure Python" stopProcessing="true"> 
      <match url="(.*)" ignoreCase="false" /> 
      <conditions> 
      <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

Wie Zusammengefasst ist das Problem das Projekt hielt die env mit Python mit 3.4.Just es auf die neue Version von Python-Interpreter ändern.

web.config Einstellungen:

<appSettings> 
    <add key="WSGI_HANDLER" value="myApp.wsgi.application"/> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> 
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot" /> 
    <add key="DJANGO_SETTINGS_MODULE" value="myApp.settings" /> 
</appSettings> 

Hoffe, es hilft.

Verwandte Themen