I have a dotnet Function App running on Azure which uses a HttpClient to call another API, but it times out after a bit (100 seconds I believe, which should be the default). I've tried updating the timeout field to 30 minutes or 60 minutes (e.g. httpClient.Timeout = TimeSpan.FromMinutes(30);
) but this doesn't change anything.
For dotnet APIs, this timeout value is set by the server, not the code, which works fine for my API (I can call the same code in a dotnet API context and it works fine), but I need to add this to my function app context. Correct me if I'm wrong, but function apps don't have a Web.config file but only use app settings/connection strings and I couldn't find an app setting for this. Any way to get around this?
Note: This is not due to the actual function apps timing out, I can still run code in the function app after the http client times out. The issue is configuring execution timeout specifically for Http client, just within a function app context
I found a solution, implement this guide here: https://thomaslevesque.com/2018/02/25/better-timeout-handling-with-httpclient/ to increase the timeout and set the cancel per-request
In my case, I'm calling another API on Azure so it has a hard limit of 230 seconds, but this is still better than 100 seconds and can actually set a timeout if I want.