Why does my Azure Function return 401 on some requests?
I have an Azure Function with an HTTP trigger that is called by Datadog monitors. When a trigger fires, Datadog sends an HTTP request to execute the function. Most of the time everything works, but in some cases the function responds with 401.
To investigate, I enabled all logs: Log Analytics and http_trigger invocations. The issue is that the failing calls do not appear in any log. This suggests that, in these situations, Datadog never actually reaches the Function endpoint the request is being blocked before the execution is even registered.
In the most recent case, Datadog recorded a 401, but this response does not appear in the Function logs, which reinforces that the request never reached the runtime.
It’s worth noting that the Datadog webhook is configured with the Function URL already containing the function key, so authentication should be correct. Even so, everything points to some kind of intermittent failure either along the request path or within Datadog itself.
Another important point: this has also happened to me when using Postman. Sometimes I get a 401, but most of the time it works normally.