Azure Event Grid topics

Azure Event Grid topics are micro components responsible for receiving and sending events from the event source to the event listener. To perform event routing, Event Grid topics follow the publish-subscribe pattern, where a source system publishes an event to an Event Grid endpoint and once the events are received, the Azure Event Grid topic uses subscription information to push the event details to multiple event listeners. 

To create and manage an Azure Event Grid topic instance in Azure Resource Group, you can follow any of these processes:

  • Use the Azure Portal
  • Use Azure Resource Manager (ARM) templates
  • Use the Azure CLI 
  • Use Azure PowerShell

To create an Event Grid topic manually through the Azure portal, you can follow the Microsoft documentation link shared here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart-portal#create-a-custom-topic.  

If you want a simplified approach through the Azure CLI, then use the following code:

abhishek@Azure:~$ az eventgrid topic create -g myresourcegroupname --name sampleintegration01 -l westus2
{
"endpoint": "https://sampleintegration01.westus2-1.eventgrid.azure.net/api/events",
"id": "/subscriptions/**************/resourceGroups/myresourcegroupname/providers/Microsoft.EventGrid/topics/sampleintegration01",
"inputSchema": "EventGridSchema",
"inputSchemaMapping": null,
"location": "westus2",
"name": "sampleintegration01",
"provisioningState": "Succeeded",
"resourceGroup": "chapter7",
"tags": null,
"type": "Microsoft.EventGrid/topics"
}

In the preceding code, myresourcegroupname is the name of the resource group under which we are required to create an Azure Event Grid topicsampleintegration01 is the name of the custom Azure Event Grid topic and WestUs2 is the location of the resource.

When publishing events to the Azure Event Grid topic, the client application must follow the required data contract structure defined by the Azure Event Grid framework for pushing events to the Azure Event Grid. Once a message is sent to the consumer application's event grid topic, the consumer application can then read the event message and react as required by the system. The following example describes one of the request events fired through a custom event grid topic:

[{
"id": "000023",
"eventType": "NewOrderCreated",
"subject": "New Order created with order number 0000123",
"eventTime": "2019-01-10T21:03:07+00:00",
"data": {
"ordernumber": "0000123",
"invoicenumber": "INV00012343",
"CustomerId": "0000023"
},
"dataVersion": "1.0",
"metadataVersion": "1",
"topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/topics/{topic}"
}
]

As we go though this chapter, we will understand more about the concept of event deserialization through the Azure Event Grid SDK. We will also become familiar with how you can post an event of your choice through Azure Event Grid.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.220.21