如何使用 Azure 警报负载来触发 azure 函数的 HTTP

问题描述

我正在尝试使用 Azure 警报在调用 Azure 函数时发送的负载

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

但在 req_body 变量中没有得到任何东西。 任何人都知道如何在 python azure 函数中使用它。

解决方法

如果要使用azure alert触发Azure Function,请参考以下步骤

  1. 创建 Azure 函数。我的代码如下
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. 创建提醒

    一个。定义条件

    B.定义操作组 enter image description here

  2. 测试 enter image description here