I have an azure function app with runtime v2
and language C#
using EventGridTrigger
. The function is subscribed to all events originating from an azure subscription. My main goal is to process events about a virtual machine's start
and stop
actions, and then perform certain actions when those events are received.
However, I am noticing delays of about 30 - 120 seconds between the EventTime
noted in the event, and the time it is received in the function app. I verified that this is not a cold start issue by making sure I restarted the app just before triggering events. It sounds more like an azure compute issue to me.
For example, I restarted my app. Then I hit the Start
button for a VM in the azure portal. After sometime, when the vm starts, azure compute sends an event to event grid, which my function app receives and just logs the event along with the event time. (see picture below).
Note that there is about 107 seconds delay between EventTime (12:44:05 AM), and when it was received and logged by the function (12:45:52 AM).
To dig deeper, I tried to check if I see similar delays when I push my own events. I created a custom topic, and subscribed another function to this topic. And then I pushed events to my custom topic using Azure Cloud Shell. In this case, I can see that my function received the event almost instantly. The delay is less than 1 second.
It indicates to me that EventGrid per se is quick, but the azure compute (VM infrastructure) is slow in pushing events. For example, if it creates an event object with EventTime
t
, but then publishes it at (t+t1)
time, then of course EventGrid can do nothing about the t1
delay that got introduced before the event reached EventGrid.
Is my understanding (/speculation) here correct? Are there ways to get notified more quickly (<10 seconds delay)?