2017-08-27 9 views
1

Visual Studioのデフォルトテンプレート(file-new-project-python-django Webアプリケーション)を使用して、DjangoでVisual Studio 2017で簡単なアプリケーションを作成しました。私はAzureのポータルからdjango PTVSをインストールし、カスタムPython拡張を追加しました。アプリはローカルに正しく動作しますが、私は、Visual Studio経由Azureのためにそれを展開した後、私はのみ表示するページにアクセスすることができます。AzureにDjangoアプリを配備するVS2017 - カスタムPython

'Your App Service app has been created.'

私はいくつかの記事(Deploy a simple VS2017 Django app to Azure - server error)を読み、次のチュートリアルに従ってきました:次のようにhttps://docs.microsoft.com/en-us/visualstudio/python/managing-python-on-azure-app-service

私のweb.configファイルに見えます:

<?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:

私はそれを動作させることができました。問題は、まだpython 3.4でenvを使い続けていたことでした。パッケージの依存性が必要なpythonの新しいバージョンが必要なので、次のようにappの設定を変更しました。

<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

こんにちは、更新はありますか? –

+0

@JayGong申し訳ありませんが、私はすでに結果を投稿したと思いました。だから私はそれを動作させることができた、問題は、それがpython 3.4でenvを使用し続けているように見えた。したがって私は、新しいpythonバージョンを使用するようにアプリの設定を変更した。 – Galdar

+0

お返事ありがとうございました。私の答えはこの問題を要約したものです。あなたは他の人のリファレンスをフォーラムに記入することができます。 –

答えて

0

問題を再現しようとしましたが、失敗しました。私のDjangoアプリはVS2017によってAzure WebAppsにデプロイされた&を作成して動作します。あなたと同じ問題があるいくつかの同様のSOスレッドがあります。

  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

もう一度試すために、上記のスレッドを追跡することができます。また、the official tutorial for Djangoを参照してdjangoアプリケーションを作成してAzureにデプロイし、web.configをPython 3.6.1拡張機能を使用するように変更することもできます。

以下は、私のweb.configファイルの内容です。ただ、要約として

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

、問題は、プロジェクトがPythonインタプリタの新しいバージョンに変更し3.4.Justのpythonでのenvを使用して保たれています。

web.configファイルの設定:

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

それがお役に立てば幸いです。