0

I am trying to consume the payload that azure alert is sending while calling an Azure function.

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    req_body = req.get_json()
    print(req_body)

but not getting anything in req_body variable. Anyone on how to consume it in python azure function.

1 Answers1

0

If you want to use azure alert to trigger Azure Function, please refer to the following steps

  1. Create Azure Function. My code is as below
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

  
    req_body = req.get_json()
    logging.info(req_body)
    return func.HttpResponse(
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
    )
  1. Create alert

    a. Define condition

    b. Define action group enter image description here

  2. Test enter image description here

Jim Xu
  • 21,610
  • 2
  • 19
  • 39
  • If it is useful for you, could you please [accept it as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)? – Jim Xu Jun 24 '21 at 07:58