Publishing event from Azure DevOps to Azure Event Grid

try the following:

https://<yourtopic>.<region><your url encoded key>

and the following is an Event Schema of the payload:

    "topic": string,
    "subject": string,
    "id": string,
    "eventType": string,
    "eventTime": string,
    "dataVersion": string,
    "metadataVersion": string


The example of the HttpTrigger function with output binding to the AEG custom topic:


#r "Newtonsoft.Json"
#r "Microsoft.Azure.EventGrid"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.Azure.EventGrid.Models;

public static async Task<IActionResult> Run(JObject body, IAsyncCollector<EventGridEvent> outputEvents, ILogger log)

    EventGridEvent ege = new EventGridEvent() {
        Topic = null,
        Id = (string)body["id"],
        EventType = (string)body["eventType"],
        EventTime = (DateTime)body["createdDate"],
        Data = body,
        DataVersion = "1",
        Subject = "abcd"
    await outputEvents.AddAsync(ege);

    return (ActionResult)new NoContentResult(); 


  "bindings": [
      "authLevel": "function",
      "name": "body",
      "type": "httpTrigger",
      "direction": "in",
      "methods": [
      "type": "eventGrid",
      "direction": "out",
      "name": "outputEvents",
      "topicEndpointUri": "AEG_TOPIC_XX_ENDPOINT",
      "topicKeySetting": "AEG_TOPIC_XX_KEY"
      "name": "$return",
      "type": "http",
      "direction": "out"

enter code here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top