Is it possible to modify http request timeout in Azure App Service - Django - django

Currently this value is around 80 seconds. I tried modifying the timeout by multiple ways:
Modifying the web.config file.
<system.web>
<httpRuntime targetFramework="4.5" executionTimeout="600"/>
</system.web>
Modifying SCM_COMMAND_IDLE_TIMEOUT value in application settings in azure portal.
One more solution I got here:
https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/. I think this doesn't apply to Azure app service.
None of these are working. Is there a way we can modify timeout value?

Change your config as per below for Python.
Set the desired requestTimeout="00:04:00"
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*"
modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\home\Python27\python.exe" arguments="manage.py runserver %HTTP_PLATFORM_PORT%" requestTimeout="00:04:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="PYTHONPATH" value="D:\home\site\wwwroot"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Read details https://prmadi.com/django-app-with-httpplatformhandler-in-azure-app-services-windows/

Related

django web server running with iis doesn't run static css js image files

I have a django web server project running on ISP and static file is not working
How do I make changes to Internet Information Services (IIS) and web cofig file for static files to work?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<!-- Required settings -->
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<!-- Your django path -->
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\pax_web_server_app" />
<!-- Your djangoname.settings -->
<add key="DJANGO_SETTINGS_MODULE" value="pax_web_server_app.settings" />
</appSettings>
<system.webServer>
<handlers>
<add name="paxsite" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python311\python.exe|C:\Python311\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" />
</handlers>
<staticContent>
<mimeMap fileExtension=".tab" mimeType="static/css" />
</staticContent>
</system.webServer>
</configuration>
I did the instructions on the microsoft website but it still didn't work
Create virtual directory in iis with the name of static and point the path to that virtual directory with your actual static folder
Here is the link you can refer for the more details:
How to fetch static CSS files with django on IIS?

IIS Django localhost opens list of directories

I am trying to deploy a Django app on IIS.
After a few days of FINALLY getting HTTP Platform Handler to work now i face another problem
right now when i go to local host i see a list of files in my Django app.
how do i make it start the Django app right away.
i am using HTTP Platform Handler.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"
requireAccess="Script" />
</handlers>
<httpPlatform startupTimeLimit="10" startupRetryCount="10" stdoutLogEnabled="true"
processPath="C:\Python310\python.exe"
arguments="manage.py runserver">
<environmentVariables>
<environmentVariable name="foo" value="bar"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
when i disable directory browsing i get an error.

Increase timeout setting for Flask Application

I have a flask application which I have configured to run on IIS7. I am using web.config file for the required flask configuration and is working great.
In my application I have a section where the user can upload a data file which for processing; per my processing needs this might take more time depending on the file size and for a bigger file the app is timing out.
I need to set the time out to a bigger number. Need help.
here is my web.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="Python27_via_FastCGI" />
<remove name="Python34_via_FastCGI" />
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="d:\anaconda3\python.exe|d:\anaconda3\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<!-- Required settings -->
<add key="WSGI_HANDLER" value="gui.app" />
<add key="PYTHONPATH" value="D:\PythonProjects\FlaskApp" />
</appSettings>
</configuration>
You can increase the timeout value in flask itself, try the following:
import requests
timeoutSeconds = 5
try:
res = requests.get(<url>, timeout=timeoutSeconds)
except:
print("Timeout")

I am facing issues while hosting my Flask web application in IIS

I am using Python3.5, IIS10 to deploy flask web application in iis. Can anyone help me to set up iis with python. I saw many examples but i could not able to do so. I guess the error must be related to web.config
My error is
HTTP Error 500.0 - Internal Server Error C:\Program Files\Python35\python.exe - The FastCGI process exceeded configured request timeout
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="Bot_Chat.app" />
<add key="PYTHONPATH" value="C:/inetpub/wwwroot/EtownChatBot/;C:\Program Files\Python35;C:\Program Files\Python35\Lib;C:\Program Files\Python35\Lib\site-packages;C:\Program Files\Python35\DLLs;" />
</appSettings>
<system.webServer>
<handlers>
<remove name="CGI-exe" />
<add name="FlaskHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\Python35\python.exe|"C:\inetpub\wwwroot\EtownChatBot\wfastcgi.py"" resourceType="Unspecified" />
</handlers>
<directoryBrowse enabled="true" />
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".py" allowed="true" />
<add fileExtension=".html" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Add applicationHost.xdt under Your Project directory..
applicationHost.xdt
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<fastCgi>
<application xdt:Locator="Match(fullPath)" xdt:Transform="SetAttributes(activityTimeout)"
fullPath="C:\Program Files\Python35\python.exe" activityTimeout="600"/>
</fastCgi>
</system.webServer>
</configuration>
Refresh and Restart your Site.Now it will work..

code issue adding ELMAH via nuget

I added
ELMAH to my website and i am getting the following error in my web.config
The inheritinChildApplications has a red squiggly meaning the compiler doesnt like it. and the location path portion is grayed out. Im new to using ELMAH, anyone have any thoughts on how to rectify this?
<location path="elmah.axd" **inheritInChildApplications="false"**>
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
-->
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
I don't know why it does that, but it's not an error as far as I know. It does that on my site and Elmah continues to work just fine.