2
votes

We have a .net core azure function on function runtime 3. This works perfectly fine ran locally and most of the time on our deployed app service. However we've experienced intermittent 404 responses for requests that go through perfectly fine at other times.

There's no entries appearing in our logs or application insights telemetry for the failing requests.

It feels a lot like this issue on the azure-function-host github project: https://github.com/Azure/azure-functions-host/issues/5247 though that's targeting functions runtime 1 or 2.

Has anyone had similar issues or know of any way to get additional log info that might highlight what problem we're running into.

1

1 Answers

1
votes

That might happen during scaling out or your function app about to change the server from one to another (for some reason). That's the actually cons of serverless applications.

But what I can suggest to you is:

  • Create HeartBeat Function similar to this:

    private readonly IAsyncRepository<Business> _businessAsyncRepository;
    
    public HeartBeat(IAsyncRepository<Business> businessAsyncRepository)
    {
        // Your all DI injections are here
        _businessAsyncRepository = businessAsyncRepository;
    }
    
    [FunctionName(nameof(HeartBeat))]
    public async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
        ILogger log)
    {
        string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
        dynamic data = JsonConvert.DeserializeObject(requestBody);
        return new OkObjectResult("OK");
    }
    

And then create availability test on Application Insights and call the HeartBeat.

enter image description here

This will also give you a warm instance of Azure Functions at all time. But obviously you spend your 1m free call on consumption plan every time you call the heartbeat depending on how frequently you call the AF.