Unexplainable 500 Internal Server error running Django App service
<p>Here are the steps I followed to set it up.</p>

<ol>
<li><p>I created a boilerplate Django app service on the Azure portal. It worked perfectly and a blank django app appeared at the URL of my app service.</p></li>
<li><p>I then copied all of the following configuration files from their boilerplate:
<a href="https://github.com/azureappserviceoss/DjangoAzure" rel="nofollow noreferrer">https://github.com/azureappserviceoss/DjangoAzure</a></p>

<ul>
<li>.skipPythonDeployment</li>
<li>azuredeploy.json</li>
<li>ptvs_virtualenv_proxy.py</li>
<li>web.config (modified this to point to my actual project settings and wsgi)</li>
<li>web.debug.config</li>
</ul></li>
<li><p>After pushing these config files to my own django project, I setup the App service on azure to point to my github repository instead of their boilerplate repository which I linked to above. It was successful in setting up continuous deployment and fetching/building the repository.</p></li>
<li><p>My app page now shows nothing but the text:</p></li>
</ol>

<blockquote>
  <p>The page cannot be displayed because an internal server error has occurred.</p>
</blockquote>

<p>The application log stream returns the following:</p>

<pre class="lang-html prettyprint-override"><code>&lt;div id="content"&gt; 
&lt;div class="content-container"&gt; 
&lt;h3&gt;HTTP Error 500.0 - Internal Server Error&lt;/h3&gt; 
&lt;h4&gt;The page cannot be displayed because an internal server error has occurred.&lt;/h4&gt; 
&lt;/div&gt; 
&lt;div class="content-container"&gt; 
&lt;fieldset&gt;&lt;h4&gt;Most likely causes:&lt;/h4&gt; 
&lt;ul&gt;    &lt;li&gt;IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.&lt;/li&gt;    &lt;li&gt;IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.&lt;/li&gt;    &lt;li&gt;IIS was not able to process configuration for the Web site or application.&lt;/li&gt;     &lt;li&gt;The authenticated user does not have permission to use this DLL.&lt;/li&gt;   &lt;li&gt;The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.&lt;/li&gt; &lt;/ul&gt; 
&lt;/fieldset&gt; 
&lt;/div&gt; 
&lt;div class="content-container"&gt; 
&lt;fieldset&gt;&lt;h4&gt;Things you can try:&lt;/h4&gt; 
&lt;ul&gt;    &lt;li&gt;Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.&lt;/li&gt;     &lt;li&gt;Check the event logs to see if any additional information was logged.&lt;/li&gt;  &lt;li&gt;Verify the permissions for the DLL.&lt;/li&gt;    &lt;li&gt;Install the .NET Extensibility feature if the request is mapped to a managed handler.&lt;/li&gt;  &lt;li&gt;Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click &lt;a href="http://go.microsoft.com/fwlink/?LinkID=66439"&gt;here&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt; 
&lt;/fieldset&gt; 
&lt;/div&gt; 

&lt;div class="content-container"&gt; 
&lt;fieldset&gt;&lt;h4&gt;Detailed Error Information:&lt;/h4&gt; 
&lt;div id="details-left"&gt; 
&lt;table border="0" cellpadding="0" cellspacing="0"&gt; 
&lt;tr class="alt"&gt;&lt;th&gt;Module&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;FastCgiModule&lt;/td&gt;&lt;/tr&gt; 
&lt;tr&gt;&lt;th&gt;Notification&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ExecuteRequestHandler&lt;/td&gt;&lt;/tr&gt; 
&lt;tr class="alt"&gt;&lt;th&gt;Handler&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Python FastCGI&lt;/td&gt;&lt;/tr&gt; 
&lt;tr&gt;&lt;th&gt;Error Code&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;0x00000000&lt;/td&gt;&lt;/tr&gt; 

&lt;/table&gt; 
&lt;/div&gt; 
&lt;div id="details-right"&gt; 
&lt;table border="0" cellpadding="0" cellspacing="0"&gt; 
&lt;tr class="alt"&gt;&lt;th&gt;Requested URL&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;http://projectone-api:80/handler.fcgi/&lt;/td&gt;&lt;/tr&gt; 
&lt;tr&gt;&lt;th&gt;Physical Path&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;D:\home\site\wwwroot\handler.fcgi\&lt;/td&gt;&lt;/tr&gt; 
&lt;tr class="alt"&gt;&lt;th&gt;Logon Method&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Anonymous&lt;/td&gt;&lt;/tr&gt; 
&lt;tr&gt;&lt;th&gt;Logon User&lt;/th&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Anonymous&lt;/td&gt;&lt;/tr&gt; 

&lt;/table&gt; 
&lt;div class="clear"&gt;&lt;/div&gt; 
&lt;/div&gt; 
&lt;/fieldset&gt; 
&lt;/div&gt; 

&lt;div class="content-container"&gt; 
&lt;fieldset&gt;&lt;h4&gt;More Information:&lt;/h4&gt; 
This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error. 
&lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;amp;IIS70Error=500,0,0x00000000,9200"&gt;View more information &amp;raquo;&lt;/a&gt;&lt;/p&gt; 
&lt;p&gt;Microsoft Knowledge Base Articles:&lt;/p&gt; 


&lt;/fieldset&gt; 
&lt;/div&gt; 
&lt;/div&gt; 
</code></pre>

<p>As requestions, here are my WSGI logs:</p>

<pre><code>2016-11-10 17:58:22.405000: wfastcgi.py 2.1.1 started
2016-11-10 17:58:22.405000: Python version: 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]
2016-11-10 17:58:22.421000: wfastcgi.py 2.1.1 initializing
2016-11-10 17:58:22.452000: Activating virtualenv with D:\home\site\wwwroot\env\Scripts\activate_this.py
2016-11-10 17:58:22.468000: Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "D:\Python27\Scripts\wfastcgi.py", line 711, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "D:\Python27\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
    return env, get_wsgi_handler(handler_name)
  File "D:\Python27\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
    handler = handler()
  File ".\ptvs_virtualenv_proxy.py", line 99, in get_virtualenv_handler
    execfile(activate_this, dict(__file__=activate_this))
IOError: [Errno 2] No such file or directory: 'D:\\home\\site\\wwwroot\\env\\Scripts\\activate_this.py'


StdOut: 

StdErr: 
2016-11-10 17:58:22.468000: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
  File "D:\Python27\Scripts\wfastcgi.py", line 711, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "D:\Python27\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
    return env, get_wsgi_handler(handler_name)
  File "D:\Python27\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
    handler = handler()
  File ".\ptvs_virtualenv_proxy.py", line 99, in get_virtualenv_handler
    execfile(activate_this, dict(__file__=activate_this))
IOError: [Errno 2] No such file or directory: 'D:\\home\\site\\wwwroot\\env\\Scripts\\activate_this.py'
2016-11-10 17:58:22.483000: wfastcgi.py 2.1.1 closed
2016-11-10 17:58:34.608000: wfastcgi.py 2.1.1 started
2016-11-10 17:58:34.624000: Python version: 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]
2016-11-10 17:58:34.624000: wfastcgi.py 2.1.1 initializing
2016-11-10 17:58:34.655000: Activating virtualenv with D:\home\site\wwwroot\env\Scripts\activate_this.py
2016-11-10 17:58:34.655000: Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "D:\Python27\Scripts\wfastcgi.py", line 711, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "D:\Python27\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
    return env, get_wsgi_handler(handler_name)
  File "D:\Python27\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
    handler = handler()
  File ".\ptvs_virtualenv_proxy.py", line 99, in get_virtualenv_handler
    execfile(activate_this, dict(__file__=activate_this))
IOError: [Errno 2] No such file or directory: 'D:\\home\\site\\wwwroot\\env\\Scripts\\activate_this.py'


StdOut: 

StdErr: 

2016-11-10 17:58:34.671000: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python27\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python27\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python27\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 99, in get_virtualenv_handler
execfile(activate_this, dict(__file__=activate_this))
IOError: [Errno 2] No such file or directory:     
'D:\\home\\site\\wwwroot\\env\\Scripts\\activate_this.py'
2016-11-10 17:58:34.687000: wfastcgi.py 2.1.1 closed
</code></pre>

<p>What's strange about this is that I don't commit my env folder to my repository because it reads my requirements.txt to create it's own. However, it seems that it is not doing that this time.</p>