Azure

How To Debug Azure Occasion Grid Set off Perform Utilizing Postman

This text demonstrates how we are able to debug an occasion grid capabilities regionally utilizing Postman. Right here, we use Azure Occasion Grid with an Azure perform as an endpoint to deal with the occasions. We are going to create a mock occasion to debug into our perform.

Utilizing postman, we are going to create the request. For that we have to type appropriate URL, HTTP headers and Payload. Let’s see these step-by-step –

STEP 1 – Create an Occasion Grid perform

A easy occasion grid set off perform created in visible studio. Right here we’re deserializing the information property contained inside the occasion into the goal object to retrieve the precise knowledge that’s supposed to deal with.

STEP 2 – The URL

We use a neighborhood URL that sends a request to set off the perform. {functionname} want to interchange with precise perform title.

http://localhost:7071/runtime/webhooks/EventGrid?functionName={functionname}

In my case, perform title is training-export

http://localhost:7071/runtime/webhooks/eventgrid?functionName=training-export

STEP 3 – Add Required HTTP Header

Add the next headers. With out these headers, request doesn’t work.

  • Content material-Sort = utility/json
  • aeg-event-type = Notification

debug an event grid functions locally using Postman

STEP 4 – Configure Payload

In request physique, occasion grid expects the request to have a sure set of fields as per outlined schema. To debug regionally we have to perceive the schema of the occasion. Schema reference has been taken from Microsoft documentation.

[
  {
    "topic": string,
    "subject": string,
    "id": string,
    "eventType": string,
    "eventTime": string,
    "data":{
      object-unique-to-each-publisher
    },
    "dataVersion": string,
    "metadataVersion": string
  }
]

To know the aim of every occasion properties, refer Microsoft documentation.

The information aspect varies relying on the totally different occasion sources. For instance – In case you are sending coaching request knowledge by way of occasion grid similar to this:

debug an event grid functions locally using Postman

This occasion JSON ought to look one thing like this with coaching request knowledge.

{
    "id": "1",
    "topic": "training-export",
    "knowledge": {
        "trainingTopic": "Debugging Occasion Grid Perform",
        "coach": "Anupam",
        "date": "2022-05-10T12:19:17.000Z"
    },
    "eventType": "ExportSuccessful",
    "dataVersion": "1",
    "metadataVersion": "1",
    "eventTime": "2022-05-16T12:31:22.2592489Z"
}

We are going to copy paste these JSON into request physique.

debug an event grid functions locally using Postman

STEP 5 – Debug and Take a look at the perform

As soon as we ship the request from postman, it should hit the perform and we are able to debug it. Right here is the console log for perform execution.

debug an event grid functions locally using Postman

Superior! We now have efficiently debug a Azure occasion grid set off perform utilizing postman.

Blissful Studying!

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button