在将我的django应用程序从免费计划扩展到azure的基本计划时,我遇到了运行时错误。这似乎是一个配置问题。这是我发现的:
访问我的网站时,出现此错误:
' /'中的服务器错误应用。 无法加载文件或程序集' Microsoft.WindowsAzure.Diagnostics,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)
一些谷歌搜索让我相信这是由Python Tools for 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 :(得分:0)
我检查了你的web.config文件的内容,除了下面的内容之外,它几乎与新的Django Azure WebApp相同。
在您的web.config文件中:
<add key="DJANGO_SETTINGS_MODULE" value="appname.settings" />
在新的Django Azure WebApp的web.config文件中:
<add key="DJANGO_SETTINGS_MODULE" value="DjangoApp.settings" />
如果wwwroot
中的django项目目录是appname
,我认为没问题。如果没有,请修改它。
同时,没有关于内部服务器错误的更多详细信息。如果您可以更新错误详细信息,我认为它对分析问题非常有帮助。如有任何疑虑,请随时告诉我。