使用来自Azure EventGrid的空负载触发Azure管道。

huangapple go评论71阅读模式
英文:

Trigger Azure Pipeline With an empty payload from Azure EventGrid

问题

我有一个API管理服务,我希望在APIM发生更改时调用Azure管道。

APIM中的事件允许通过EventGrid创建Webhook。但是,我想知道如何使用空的JSON负载调用终点。

根据运行 - 运行管道,我们可以通过RestApi运行管道。我正在配置此终点并设置正确的标头。

Postman中,我可以使用以下方式调用运行管道终点:

curl --location --request POST 'https://dev.azure.com/organization/project/_apis/pipelines/pipelineId/runs' \
--header 'Accept: api-version=7.0' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic PAT' \
--data '{}'

在APIM中 => 创建事件订阅 => 事件网格的交付属性 自定义交付属性 中,我找不到如何添加空负载。从Postman发送请求时需要这个空负载。

那么如何在EventGrid Webhook中像上面的请求中添加空负载呢?

英文:

I have an API Management service that I would like to call an Azure pipeline when changes occur in the APIM.

The Event in APIM allows the creation of a webhook through EventGrid. however, I am looking at how to call the endpoint with the empty JSON payload.

According to Runs - Run Pipeline we can run the pipeline through RestApi. I am configuring this endpoint with the correct headers.

From Postman I can call the Run Pipeline endpoint with the below;

curl --location --request POST 'https://dev.azure.com/organization/project/_apis/pipelines/pipelineId/runs' \
--header 'Accept: api-version=7.0' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic PAT'
--data '{}'

In the APIM => Create Event Subscription => Delivery Properties Custom delivery properties
of EventGrid, I couldn't find a way to add an empty payload. This empty payload is required while sending a request from the Postman.

So how to add an empty payload to the request as above in the EventGrid Webhook?

答案1

得分: 0

  1. 使用 WebHook 事件传递 时,事件网格会执行所述的握手操作,以使其正常工作,并始终包括有效负载。

  2. 您应使用不同的服务代理请求。以下是一些选项:

    1. 使用 APIM
    这是使用相同的 APIM 实例获取事件网格事件并将其转发到 DevOps API。

    此处 提供了一个自定义策略示例供参考。

    2. 使用 Azure Functions
    Azure Functions的绑定会处理此操作,由于这是基于代码的,您可以在调用 DevOps API 之前执行任何其他所需操作或处理。

    请查看官方文档,了解如何将 Azure Functions 用作事件处理程序

英文:

When using WebHook Event Delivery, Event Grid performs a handshake as documented for it to work and always includes a payload.

You should proxy the request using a different service. Here are some options

1. Use APIM
This is to use the same APIM instance to get the Event Grid event and forward it to the DevOps API.

Here is a custom policy example to get started.

2. Use Azure Functions
The binding for Azure Functions handles this for you, and since this is code-based, you can perform any other action or processing required before calling the DevOps API.

Check the official docs for how Azure Functions can be used as an event handler.

huangapple
  • 本文由 发表于 2023年4月13日 23:35:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007300.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定