Azure Function App throwing 500 error Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException on initial call after .net 8 upgrade and change from in-process model to isolated. Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException

Purav Upadhyay 0 Reputation points
2024-11-13T13:24:50.1966667+00:00

Hi. I carried out an upgrade for Azure Functions from V3 to V4. I also upgrade from .net 6 to .net 8 as well as from in-process to isolated worker model. The functions throw a 500 exception on initial call then it works as normal. It sometimes throws it again after leaving it idle for a couple of hours or more. It seems like a well known 'cold-start' issue but how do I fix it? I am happy to share more info.

Here're the group of exceptions I am getting:

Result: Function 'MyEndpoint', Invocation id '9287f530-068e-4755-be29-f31e854ea399': An exception was thrown by the invocation.
Exception: System.TimeoutException: Timed out waiting for the function start call. Invocation: '9287f530-068e-4755-be29-f31e854ea399'.
 ---> System.TimeoutException: The operation has timed out.
   at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in /mnt/vss/_work/1/s/extensions/Worker.Extensions.Http.AspNetCore/src/Coordinator/DefaultHttpCoordinator.cs:line 56
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in /mnt/vss/_work/1/s/extensions/Worker.Extensions.Http.AspNetCore/src/Coordinator/DefaultHttpCoordinator.cs:line 67
   at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in /mnt/vss/_work/1/s/extensions/Worker.Extensions.Http.AspNetCore/src/FunctionsMiddleware/FunctionsHttpProxyingMiddleware.cs:line 45
   at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 91
Stack:    at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in /mnt/vss/_work/1/s/extensions/Worker.Extensions.Http.AspNetCore/src/Coordinator/DefaultHttpCoordinator.cs:line 67
   at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in /mnt/vss/_work/1/s/extensions/Worker.Extensions.Http.AspNetCore/src/FunctionsMiddleware/FunctionsHttpProxyingMiddleware.cs:line 45
   at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 91 
Timed out waiting for the function start call. Invocation: '9287f530-068e-4755-be29-f31e854ea399'. The operation has timed out.
Exception while executing function: Functions.MyEndpoint Failed to proxy request with ForwarderError: Request An attempt was made to access a socket in a way forbidden by its access permissions. (localhost:49381) An attempt was made to access a socket in a way forbidden by its access permissions. 

Here's screenshot from the Application Insights
User's image

Thanks in advance.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,194 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 5,230 Reputation points Microsoft Employee
    2024-11-15T13:01:08.9733333+00:00

    Hello @Purav Upadhyay The error message you provided indicates that the function is timing out while waiting for the function start call. This is a common issue with Azure Functions, especially when using the isolated worker model.

    To fix this issue, you can try the following:

    1. Increase the function's timeout value. You can do this by setting the functionTimeout property in the host.json file. For example, you can set it to 5 minutes like this:
    { "functionTimeout": "00:05:00" }
    
    1. Enable the WEBSITE\_USE\_PLACEHOLDER environment variable. This environment variable can help reduce cold-start times by pre-warming the function app. You can enable it by adding the following app setting to your function app:
    { "name": "WEBSITE_USE_PLACEHOLDER", "value": "1" }
    
    1. Use the WEBSITE\_RUN\_FROM\_PACKAGE environment variable. This environment variable can help reduce cold-start times by pre-warming the function app. You can enable it by adding the following app setting to your function app:
    { "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1" }
    
    1. Use the WEBSITE\_ZIP\_DEPLOY\_SKIP\_DURABILITY environment variable. This environment variable can help reduce cold-start times by skipping the durability checks during deployment. You can enable it by adding the following app setting to your function app:
    { "name": "WEBSITE_ZIP_DEPLOY_SKIP_DURABILITY", "value": "1" }
    

    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.