Christian Coan
Christian Coan

Reputation: 97

HTTP timeout when making long running HTTP request from Azure Function

I am currently writing an Azure Function application to generate large PDF’s from HTML. I have an Azure Service Bus queue that gets pushed to via a website and then the queue messages get processed by the Azure Function (Basic Tier App Service Plan)

To generate the PDF’s, I make a HTTP request to an Azure Cloud Service from within the Azure function which generates me a byte array for which I write to Azure Blob Storage.

Sometimes the HTTP request can take up to 30 minutes. When I make any HTTP request at the moment that is longer than 4 minutes 30 seconds, I never get a response back. If my assumptions are correct, it’s due to the connection between the Cloud Service and the Azure Function timing out.

Has anyone got any suggestions which would allow for longer running HTTP requests using this infrastructure?

Upvotes: 1

Views: 3859

Answers (1)

kwill
kwill

Reputation: 10998

You are likely hitting the idle timeout on the cloud service side. To fix this, set the idleTimeoutInMinutes on the InputEndpoint (https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-configuration-and-management-faq#how-do-i-set-the-idle-timeout-for-azure-load-balancer):

<Endpoints>
   <InputEndpoint name="Endpoint1" protocol="tcp" port="10100" idleTimeoutInMinutes="30" />
</Endpoints>

However this is probably the wrong solution. You should not design a system that requires a response from an active HTTP connection for 30 minutes. There are too many variables that can cause the connection to fail. You should use an async model where you call the cloud service to start the job which will return a jobid, then periodically call the cloud service to check the status of the job. See https://learn.microsoft.com/en-us/azure/architecture/patterns/async-request-reply for a design pattern.

Upvotes: 3

Related Questions