I have azure api management instance which contains one operation which has backend call to azure function. I am facing issue that client who is calling my apim endpoint receiving 500 error due to timeout at forward-request (after 30 sec), but at the backend processing continues and records are created in backend.
So in this situation client think record is not created but actually its created.
1. What is the default timeout for APIM as documentation shows 300 seconds whereas it also states 240 as max timeout? So this is misleading
2. Backend processing doesn't stop so is this expected that apim is returning timeout error?
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 a few services which are behind Azure API Managment.
When client send a request it looks like below:
Client -> Azure Api Managment -> Service A -> Service B
Sometimes Service B responses after 5min, but in the meantime Client gets 504 Gateway timeout.
In Azure API Managment I set policy
<backend>
<forward-request timeout="300" />
</backend>
In documentation I saw below information, but if it is possible to set some settings for network infrastructure in the pipeline?
The amount of time in seconds to wait for the HTTP response headers to
be returned by the backend service before a timeout error is raised.
Minimum value is 0 seconds. Values greater than 240 seconds may not be
honored as the underlying network infrastructure can drop idle
connections after this time.
As the doco indicated, any value greater than 240 won't be reliable. So the best bet for you is to change the implementation a bit if that's in your control.
A simple one could be: instead of waiting for 5 mins, you change the request to "fire and forget", and once Service B has finished its execution, it can write the response somewhere the Service A can access. Your client can then keep pinging to see if the response is available.
This may not be feasible if you don't have control, but just suggested it as a workaround in case you do :)
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"
}
I am trying to get a list of all Storage Accounts present in my Azure subscription but I am getting a throttling error.
com.microsoft.azure.CloudException: Status code 429, {"error":{"code":"ResourceCollectionRequestsThrottled","message":"Operation 'Microsoft.Storage/storageAccounts/read' failed as server encountered too many requests. Please try after '17' seconds. Tracking Id is 'e982a894-0f3e-4291-a9b3-e147c18f8f60'."}}
The request prior to this request prints there are 13869 more remaining subscription reads but it still fails.
x-ms-ratelimit-remaining-subscription-reads: 13869
There are around 60 Storage Accounts in my subscription and that according is a small number.
Any idea what's causing this and that too only while listing Storage Accounts and nowhere else.
According to this article:
For each subscription and tenant, Resource Manager limits read requests to 15,000 per hour and write requests to 1,200 per hour. These limits apply to each Azure Resource Manager instance; there are multiple instances in every Azure region, and Azure Resource Manager is deployed to all Azure regions. So, in practice, limits are effectively much higher than those listed above, as user requests are generally serviced by many different instances.
If your application or script reaches these limits, you need to throttle your requests.
So if you reach the request limit, Resource Manager returns the 429 HTTP status code and a Retry-After value in the header. The Retry-After value specifies the number of seconds your application should wait (or sleep) before sending the next request. If you send a request before the retry value has elapsed, your request is not processed and a new retry value is returned.
I suggest you could use this way to get the number of the read time. If it will meet the limit, you could write codes to limit the application to send the request.
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.