1

I am getting a runtime error when scaling up my django app from a free plan to a basic plan on azure. It appears to be a configuration problem. Here is what I have found:

When visiting my site, I get this error:

Server Error in '/' Application. Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Some googling led me to believe that this is a bug with the auto generated config file created by Python Tools for Visual Studio. This issue is documented on the PTVS Github project. That issue references a potential workaround from the msdn blog. However, when I replace my config file with the one suggested on msdn (after changing references of python 3.5 to 2.7), I get an internal server error.

This is my original config file.

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

Edit: I am getting a logging error:

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

I really appreciate any help!

bkramer
  • 49
  • 1
  • 8

1 Answers1

0

I checked the content of your web.config file which is almost as same as the one of a new Django Azure WebApp, besides the content as below.

In your web.config file:

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

In the web.config file of a new Django Azure WebApp:

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

If the django project directory in your wwwroot is appname, I think it's OK. If not, please modify it.

Meanwhile, there is no more detail information about the interal server error. If you can update the error details, I think it's very helpful for analysising the issue. Any concern, please feel free to let me know.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • The project directory name is 'appname'. I have edited in a logging error. Let me know if you want more information. – bkramer Nov 30 '16 at 15:49