Alert action group sends GET instead of POST to Azure function

Vilse 1 Reputation point
2022-10-06T09:07:59.193+00:00

I'm trying to send Azure Monitor alerts to an Azure function for further processing.

I have set up an alert that has an action group with two targets: email and a function. Currently the function does nothing except log the event it receives.

When the alert is triggered, I get an email with details of the alert. The function is also called via HttpTrigger, but it merely receives an empty GET request to the URL of the function. The request does not have any information of the alert.

However, if I go edit my action group, there is a button "Test action group (preview)". If I send a metric alert sample, my function receives a POST request with information of the sample alert in the body. How can I receive similar POST from my real alerts?

In the action group actions, I am using the common alert schema. I have tried both "Azure function" and "Webhook" action types, and they both send an empty GET request to the function URL I specify. I have specified the code query param with the function key, and if I add some other static query params to the URL, I can see those in the function.

Here's the function.json:

{  
  "bindings": [  
    {  
      "authLevel": "function",  
      "type": "httpTrigger",  
      "direction": "in",  
      "name": "req"  
    },  
    {  
      "type": "http",  
      "direction": "out",  
      "name": "res"  
    }  
  ]  
}  

For what it's worth, I'm using Terraform but the same issue persists even when I configure the connections manually from the Web UI.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,873 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,404 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vilse 1 Reputation point
    2022-10-06T10:24:11.587+00:00

    I managed to fix this and the problem was painfully simple.

    I had configured the function trigger URL (in Terraform azure_function_receiver http_trigger_url) with http:// instead of https://. This caused a redirect inside Azure which changed the POST request into a GET request and dropping the message body. I added the missing "s" and now it works.