azure-functions-host: Unexpected delay before message processing in EventGridTrigger
Is your question related to a specific version? If so, please specify:
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
What language does your question apply to? (e.g. C#, JavaScript, Java, All)
C#
Question
I see that the code execution time inside the Azure Function is 2s, but event handler shows that the total time is a few minutes Why do some messages from EventGrid are waiting so long before start actual processing?
public class Handler
{
[FunctionName("Handler")]
[Singleton]
public async Task Run([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log)
{
log.LogInformation("Event:");
}
}

About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 4
- Comments: 18
Hi, We experience the same behaviour on our functions. About 0.48 percent of events, gets a delayed delivery of exactly 3 minutes. We thought we had a computationally slow function and in order to diagnose the behaviour, we created a new function in a separate Resource group, separate Application Insights to log to and a Windows Consumption AppService Plan. However, this “logging function” shows the same behaviour.
Common between the functions
The new “logging function” contains nothing except the following code:
The service that publishes the events of the topic should not be the culprit according to these Azure EventGrid metrics where you can see the publisher has a constant publishing latency and the destination functions fluctuate wildly. The functions get triggered approx 50000-100000 times a day.
The weird thing is that the slow function shows the same behaviour as for the author. Here is an example of an function execution that takes 10 seconds, all dependency calls are intra-azure within the same data center location.
I’ve also found this in the docs: Event Grid automatically adjusts the rate at which events are delivered to a function triggered by an Event Grid event based on the perceived rate at which the function can process events. This rate match feature averts delivery errors that stem from the inability of a function to process events as the function’s event processing rate can vary over time.. Is this what we’re experiencing? Any ideas are greatly appreciated.
We have experienced the same issue and reached out to Azure support, which unfortunately did not yield a conclusion.
We have implemented two solutions that seemed to have worked for us:
It is quite concerning that this problem does not appear to be receiving the necessary attention, and no definitive cause has been identified yet.
Based on my observations, it seems that this issue may be specific to Event Grid topics when used with webhook subscriptions. It could be related to the delayed delivery feature. However, without confirmation, we lack certainty on how to handle events that require low-latency delivery in our systems.
I sincerely hope that someone from Azure can provide some insight into this matter.
We are also having this problem. Events are being delayed and only reach the function within a couple of minutes while there seems to be no problem with the azure function. The same happens for web hook deliveries to an azure app service. Has there been any other information on this topic?
Thank you for the details @oleksandr-slys , We will check the logs to understand the error and revert back the findings.