2016-11-29 30 views
1

从免费计划向azure扩展我的django应用程序到基本计划时,出现运行时错误。这似乎是一个配置问题。以下是我发现:从免费应用程序扩展django应用程序时出现运行时错误至基本应用程序服务

当访问我的网站,我得到这个错误:

服务器错误“/”应用。 无法加载文件或程序集'Microsoft.WindowsAzure.Diagnostics,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其某个依赖项。定位的程序集清单定义与程序集引用不匹配。 (来自HRESULT的例外:0x80131040)

一些Google搜索引导我相信这是由Python工具为Visual Studio创建的自动生成的配置文件的错误。此问题记录在PTVS Github project上。该问题引用了msdn blog的潜在解决方法。但是,当我使用msdn上建议的配置文件(在将python 3.5的引用更改为2.7之后)替换我的配置文件时,出现内部服务器错误。

这是我的原始配置文件。

<?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="appname.settings" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
     <add name="Python FastCGI" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\Python27\python.exe|D:\Python27\Scripts\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> 

编辑:我得到一个记录错误:

2016-11-30T15:28:04 
System.ApplicationException: The trace listener AzureBlobTraceListener is disabled. ---> System.InvalidOperationException: The SAS URL for the cloud storage account is not specified. Use the environment variable 'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL' to define it. 
    at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.RefreshConfig() 
    --- End of inner exception stack trace --- 

我真的很感激任何帮助!

回答

0

我检查了web.config文件的内容,它几乎与新的Django Azure WebApp相同,除了下面的内容。

在你的web.config文件:

<add key="DJANGO_SETTINGS_MODULE" value="appname.settings" /> 

在一个新的Django Web应用程序天青的web.config文件:

<add key="DJANGO_SETTINGS_MODULE" value="DjangoApp.settings" /> 

如果Django项目目录在你wwwrootappname,我觉得没关系。如果不是,请修改它。

同时,没有关于内部服务器错误的更多详细信息。如果您可以更新错误详情,我认为这对分析问题非常有帮助。任何问题,请随时让我知道。

+0

项目目录名是'appname'。我编辑了一个记录错误。让我知道你是否想要更多信息。 – bkramer

相关问题