Why does my Azure Function return 401 on some requests?

Silva, Bruno 0 Reputation points
2025-12-02T17:24:03.4233333+00:00

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.
User's image

User's image

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.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
{count} votes

1 answer

Sort by: Most helpful
  1. Pravallika KV 3,470 Reputation points Microsoft External Staff Moderator
    2025-12-02T17:56:42.3066667+00:00

    Hi Silva, Bruno,

    Thanks for reaching out to Microsoft Q&A.

    Verify that your Azure Function's authentication settings are correctly configured. Go to your Azure Function in the Azure portal, select Authentication/Authorization, and ensure that it's set up to accept requests with the correct keys or tokens.

    • Confirm that the requests from Datadog and Postman include a valid bearer token in the Authorization header. For example:
        Authorization: Bearer <valid_access_token>
      

    If the token is not being generated or passed correctly, it could lead to a 401 error.

    • Make sure that the Function URL includes a valid function key, especially since you mentioned it is already configured that way. Check if the keys used are active and haven't expired.
    • If your Function App is configured with virtual network restrictions, ensure that the requests from Datadog are allowed through the network security group (NSG) rules. Review any inbound traffic restrictions that may be blocking the requests.
    • Enable detailed diagnostic logs in the Azure portal. This can provide insights into what might be failing during the authentication process.
    • Try using curl or another HTTP client to see if the behavior persists. This can help isolate whether it's a Datadog-specific issue or something broader.
    0 comments No comments

Your answer

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