I have hosted an Asp.NET MVC application on Azure App Service. I am getting a timeout exception which elapsed more than 230 seconds. How can increase it on Azure App Service?
As far as I know, 230 seconds is the maximum amount of time that a request can take without sending any data back to the response.
We couldn't increase it in azure web app.
Here are two work around.
One is you could move your application to a cloud service or created a VM where you have control over those settings.
Another way, you could also use async pattern in MVC.
For example:
Firstly, you could send the request to the MVC to tell the server start to work and returns an http 202.
Then you could send request every seconds or minutes from client to check the server work. If it works completely return 200 to tell the client has already completely.
Related
I have a logic app that gets called from APIM > Function > Logic app > D365 (synchronous call based on http request trigger). When I call it the first time (after a day, or after a few hours), takes longer than usual (around 25-30 seconds) and results in a Gateway timeout error.
When I call it the second time, it usually completes the operation within 8-10 secs with no timeouts.
The error message is typical:
The execution of template action 'Response_-_to_be_displayed' is failed: the client application timed out waiting for a response from service. This means that workflow took longer to respond than the alloted timeout value. The connection maintained between the client application and service will be closed and client application will get an HTTP status code 504 Gateway Timeout.
While keeping the pattern synchronous, i don't think this is something that may cause a timeout issue. I have already checked this link and this one too, but that's not a solution to my problem.
I want to keep the call synchronous (it's only a 25-30 sec call), is it something to do with an APIM policy or any settings in logic apps that can increase this?
you can increase the timeout in both logic app and APIM. In the case of APIM we implement a policy, which will dictate the timeout and in logic app it's app settings.
But in case of APIM if the timeout is more than 240 sec then APIM won't be reliable, and it is advised to look for the implementation of the function.
Now to increase the timeout in APIM we must set up the forward request policy and this policy has the attribute of timeout which you can set to your desired limit.
Go to policy fragments in APIM and add the following to a policy
<forward-request timeout="60"/>
Now regarding the logic-app, we can setup custom timeout by setting up application settings. For this you would need two setting one is threshold and other one is time out. you have to add these in app setting which is under configuration in portal for logic app.
The settings are called
Runtime.FlowRetentionThreshold
and
Runtime.Backend.FlowRunTimeout
the values of these settings are in format Days.hours:Minutes:seconds for example : 00.00:05:00 this one is for 5 minutes
Also please check that your function is working properly as workflow timeout in logic apps and apim timeouts default value is more than the time it takes to execute a task according to you.
Refer this msDoc on Logic app timeout
Refer this msdoc on apim timeout.
I have created an F1 Free Azure App Service running my current portfolio.
But.. If I check again after about an hour, I will not be able to access it.
If I wait another minute, I can reconnect, but I can't do that.
Isn't there a good way?
Should I use a LinuxVM or WindowsServerVM?
In App Service, the application will be unloaded if it is idle for 20 minutes (I think): https://learn.microsoft.com/en-us/azure/app-service/faq-availability-performance-application-issues#how-do-i-decrease-the-response-time-for-the-first-request-after-idle-time. Always On or some service sending a request to the application every 10 minutes can prevent this. Always On is not available in free tier though.
So I am testing Azure App Configuration.
https://learn.microsoft.com/en-us/azure/azure-app-configuration/quickstart-dotnet-core-app
I am trying free plan for this, which has 1000 requests limit.
My App Config store would have somewhere around 50 configs stored in it, which I retrieved in my startup.cs file, which, I guess is loaded only once when I start my Azure Functions.
But to my surprise, after testing it for a couple of times, it's returning 429 - Request throttled.
So my question is, how Azure counts request to App Config? Is it per store or per config key-value?
Requests to App Configuration is counted per store. Given you have 50 config settings, they should be all retrieved with just one request. You may like to check the "total request count" graph on the overview page of the Azure portal to learn more of your usage. The link below also has a few suggestions about how to reduce the requests.
https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-best-practices#reduce-requests-made-to-app-configuration
I know this has been asked before, but I tried all known solutions and still no luck. I have a request that returns roughly 26MB of JSON. It is returning a 502 on my azure web app. I have set maxRequestLength and maxAllowedContentLength to their max allowed values as detailed here.
How to set the maxAllowedContentLength to 500MB while running on IIS7?
I have also set the applicationHost.xdt on the site folder of my webapp and verified it is applied as detailed here.
ApplicationHost.xdt in Azure Web Apps
None the less, my request timeout at exactly 4 minutes every time. I can run the same request against my localhost running on iisexpress pointed to the Azure SQL database and it returns the data, so I know this is something azure webapp speciic.
I have enabled all types of logging in "App Service Logs" section of my webapp. I see other failed request traces for 401 when session expires, but this request doesn't log a failed request trace, or an application error. In live log stream it shows the request as a 200 response in the web server logs.
Any other ideas?
Thanks for a detailed question and sharing the solutions that you have already tried. I'm unsure if "Always ON" feature is turned on on your WebApp. Such time-out error may occur due this,so kindly enable it and let us know for further investigation.
Additional information, Azure Load Balancer has a default idle timeout setting of approximately four minutes (230 sec); this is a general idle request timeout that will cause clients to get disconnected after 230 seconds. However, the command will still continue running server-side after that. For a typical scenario, this is generally a reasonable response time limit for a web request. In such scenarios, you could look at async methods to run additional reports. WebJobs or Azure Functions is another option.
If ‘Always On’ config is not turned On, please do turn it on. The AlwaysOn would help keep the app loaded even when there's no traffic, it will send a request to the ROOT of your application. Whatever file is delivered when a request is made to / is the one which will be warmed up and this feature comes with the App Service Plan is not charged separately
1) From the Azure Portal, go to your WebApp.
2) Select Settings> Configuration > General settings.
3) For Always On, select On.
I've specified a timeout on my http trigger azure functions (v1) by specifying the following in my host.json file
{
"functionTimeout": "00:10:00"
}
I've deployed to Azure using VS2017 and can confirm that this setting now appears in the Azure Portal. I also restarted the function app just to be sure.
When I execute my function, it is always timing out on or around 4 minutes, even though the timeout has been set to 10 minutes
I've ruled out the timeout occurring from other sources as when I test the Azure function locally it does not time out.
Can anyone shed some light on why this is happening?
It is expected. Http request has a fixed timeout setting on Azure site. See Azure Web App timeout setting of 230s. In this aspect, there's no difference between Azure Web app and Http trigger Azure Function.
There is a 230 second (i.e. a little less than 4 mins) timeout for requests that are not sending any data back. After that, the client gets the 500 you saw, even though in reality the request is allowed to continue server side.
As for how to bypass this limitation, if it's not necessary to get an immediate feedback like httpresponse, you can use queue trigger to do your job.
Otherwise, have a look at Durable function. You could send an http request to start an orchestrator and get a response that it starts successfully and so on. The work is being processed in orchestrator and activity function and we don't need to worry about time out(as they are non-http trigger as well).
Azure Functions team at Microsoft has added a configuration option that enables an Azure Functions App to have the timeout increased.
Full answer #Build5Nines.com Azure Functions: Extend Execution Timeout Past 5 Minutes
In short edit host.json and set functionTimeout:
// Set functionTimeout to 10 minutes
{
"functionTimeout": "00:10:00"
}