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?
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.