Skip to content

Commit 799ef3b

Browse files
authored
Merge pull request #279224 from ShawnJackson/custom-event-quickstarts
[AQ] edit pass: Event Grid quickstarts for custom events
2 parents 24b2bc5 + 36d6093 commit 799ef3b

File tree

3 files changed

+246
-196
lines changed

3 files changed

+246
-196
lines changed

articles/event-grid/custom-event-to-eventhub.md

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
---
2-
title: 'Quickstart: Send custom events to Event Hubs - Event Grid, Azure CLI'
3-
description: 'Quickstart: Use Azure Event Grid and Azure CLI to publish a topic, and subscribe to that event. An event hub is used for the endpoint.'
2+
title: 'Quickstart: Send custom events to an event hub - Event Grid, Azure CLI'
3+
description: Learn how to use Azure Event Grid and the Azure CLI to publish a topic and subscribe to that event, by using an event hub for the endpoint.
44
ms.date: 01/31/2024
55
ms.topic: quickstart
66
ms.custom: devx-track-azurecli, mode-api
77
---
88

9-
# Quickstart: Route custom events to Azure Event Hubs with Azure CLI and Event Grid
9+
# Quickstart: Route custom events to an event hub by using Event Grid and the Azure CLI
1010

11-
[Azure Event Grid](overview.md) is a highly scalable and serverless event broker that you can use to integrate applications using events. Event Grid delivers events to [supported event handlers](event-handlers.md) and Azure Event Hubs is one of them. In this article, you use Azure CLI for the following steps:
11+
[Azure Event Grid](overview.md) is a highly scalable and serverless event broker that you can use to integrate applications via events. Event Grid delivers events to [supported event handlers](event-handlers.md), and Azure Event Hubs is one of them.
1212

13-
1. Create an Event Grid custom topic.
14-
1. Create an Azure Event Hubs subscription for the custom topic.
15-
1. Send sample events to the custom topic.
16-
1. Verify that those events are delivered to the event hub.
13+
In this quickstart, you use the Azure CLI to create an Event Grid custom topic and an Event Hubs subscription for that topic. You then send sample events to the custom topic and verify that those events are delivered to an event hub.
1714

1815
[!INCLUDE [quickstarts-free-trial-note.md](../../includes/quickstarts-free-trial-note.md)]
1916

2017
## Create a resource group
2118

22-
Event Grid topics are Azure resources, and must be placed in an Azure resource group. The resource group is a logical collection into which Azure resources are deployed and managed.
19+
Event Grid topics are Azure resources, and they must be placed in an Azure resource group. The resource group is a logical collection into which Azure resources are deployed and managed.
2320

24-
Create a resource group with the [az group create](/cli/azure/group#az-group-create) command. The following example creates a resource group named **gridResourceGroup** in the **westus2** location.
21+
Create a resource group by using the [az group create](/cli/azure/group#az-group-create) command. The following example creates a resource group named `gridResourceGroup` in the `westus2` location.
2522

26-
> [!NOTE]
27-
> Select **Try it** next to the CLI example to launch Cloud Shell in the right pane. Select **Copy** button to copy the command, paste it in the Cloud Shell window, and then press ENTER to run the command.
23+
Select **Open Cloud Shell** to open Azure Cloud Shell on the right pane. Select the **Copy** button to copy the command, paste it in Cloud Shell, and then select the Enter key to run the command.
2824

2925
```azurecli-interactive
3026
az group create --name gridResourceGroup --location westus2
@@ -34,30 +30,33 @@ az group create --name gridResourceGroup --location westus2
3430

3531
## Create a custom topic
3632

37-
An Event Grid topic provides a user-defined endpoint that you post your events to. The following example creates the custom topic in your resource group. Replace `<topic_name>` with a unique name for your custom topic. The Event Grid topic name must be unique because it's represented by a Domain Name System (DNS) entry.
33+
An Event Grid topic provides a user-defined endpoint that you post your events to. The following example creates the custom topic in your resource group.
3834

39-
1. Specify a name for the topic.
35+
Replace `<TOPIC NAME>` with a unique name for your custom topic. The Event Grid topic name must be unique because a Domain Name System (DNS) entry represents it.
36+
37+
1. Specify a name for the topic:
4038

4139
```azurecli-interactive
4240
topicname="<TOPIC NAME>"
43-
```
44-
1. Run the following command to create the topic.
41+
```
42+
43+
1. Run the following command to create the topic:
4544
4645
```azurecli-interactive
4746
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
4847
```
4948
5049
## Create an event hub
5150
52-
Before subscribing to the custom topic, let's create the endpoint for the event message. You create an event hub for collecting the events.
51+
Before you subscribe to the custom topic, create the endpoint for the event message. You create an event hub for collecting the events.
5352
54-
1. Specify a unique name for the Event Hubs namespace.
53+
1. Specify a unique name for the Event Hubs namespace:
5554
5655
```azurecli-interactive
5756
namespace="<EVENT HUBS NAMESPACE NAME>"
5857
```
59-
1. Run the following commands to create an Event Hubs namespace and an event hub named `demohub` in that namespace.
6058
59+
1. Run the following commands to create an Event Hubs namespace and an event hub named `demohub` in that namespace:
6160
6261
```azurecli-interactive
6362
hubname=demohub
@@ -68,11 +67,11 @@ Before subscribing to the custom topic, let's create the endpoint for the event
6867
6968
## Subscribe to a custom topic
7069
71-
You subscribe to an Event Grid topic to tell Event Grid which events you want to track. The following example subscribes to the custom topic you created, and passes the resource ID of the event hub for the endpoint. The endpoint is in the format:
70+
You subscribe to an Event Grid topic to tell Event Grid which events you want to track. The following example subscribes to the custom topic that you created, and it passes the resource ID of the event hub for the endpoint. The endpoint is in this format:
7271
7372
`/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.EventHub/namespaces/<NAMESPACE NAME>/eventhubs/<EVENT HUB NAME>`
7473
75-
The following script gets the resource ID for the event hub, and subscribes to an Event Grid topic. It sets the endpoint type to `eventhub` and uses the event hub ID for the endpoint.
74+
The following script gets the resource ID for the event hub and subscribes to an Event Grid topic. It sets the endpoint type to `eventhub` and uses the event hub ID for the endpoint.
7675
7776
```azurecli-interactive
7877
hubid=$(az eventhubs eventhub show --name $hubname --namespace-name $namespace --resource-group gridResourceGroup --query id --output tsv)
@@ -89,14 +88,16 @@ The account that creates the event subscription must have write access to the ev
8988

9089
## Send an event to your custom topic
9190

92-
Let's trigger an event to see how Event Grid distributes the message to your endpoint. First, let's get the URL and key for the custom topic.
91+
Trigger an event to see how Event Grid distributes the message to your endpoint. First, get the URL and key for the custom topic:
9392

9493
```azurecli-interactive
9594
endpoint=$(az eventgrid topic show --name $topicname -g gridResourceGroup --query "endpoint" --output tsv)
9695
key=$(az eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv)
9796
```
9897

99-
To simplify this article, you use sample event data to send to the custom topic. Typically, an application or Azure service would send the event data. CURL is a utility that sends HTTP requests. In this article, use CURL to send the event to the custom topic. The following example sends three events to the Event Grid topic:
98+
For the sake of simplicity in this article, you use sample event data to send to the custom topic. Typically, an application or an Azure service would send the event data.
99+
100+
The cURL tool sends HTTP requests. In this article, you use cURL to send the event to the custom topic. The following example sends three events to the Event Grid topic:
100101

101102
```azurecli-interactive
102103
for i in 1 2 3
@@ -106,33 +107,34 @@ do
106107
done
107108
```
108109

109-
On the **Overview** page for your Event Hubs namespace in the Azure portal, notice that Event Grid sent those three events to the event hub. You see the same chart on the **Overview** page for the `demohub` Event Hubs instance page.
110+
In the Azure portal, on the **Overview** page for your Event Hubs namespace, notice that Event Grid sent those three events to the event hub. You see the same chart on the **Overview** page for the `demohub` Event Hubs instance.
110111

111-
:::image type="content" source="./media/custom-event-to-eventhub/show-result.png" lightbox="./media/custom-event-to-eventhub/show-result.png" alt-text="Image showing the portal page with incoming message count as 3.":::
112+
:::image type="content" source="./media/custom-event-to-eventhub/show-result.png" lightbox="./media/custom-event-to-eventhub/show-result.png" alt-text="Screenshot that shows the portal page with an incoming message count of 3.":::
112113

113-
Typically, you create an application that retrieves the events from the event hub. To create an application that gets messages from an event hub, see:
114+
Typically, you create an application that retrieves event messages from the event hub. For more information, see:
114115

115-
* [Get started receiving messages with the Event Processor Host in .NET Standard](../event-hubs/event-hubs-dotnet-standard-getstarted-send.md)
116-
* [Receive events from Azure Event Hubs using Java](../event-hubs/event-hubs-java-get-started-send.md)
117-
* [Receive events from Event Hubs using Apache Storm](../event-hubs/event-hubs-storm-getstarted-receive.md)
116+
- [Get started receiving messages with the event processor host in .NET Standard](../event-hubs/event-hubs-dotnet-standard-getstarted-send.md)
117+
- [Receive events from Azure Event Hubs by using Java](../event-hubs/event-hubs-java-get-started-send.md)
118+
- [Receive events from Event Hubs by using Apache Storm](../event-hubs/event-hubs-storm-getstarted-receive.md)
118119

119120
## Clean up resources
120-
If you plan to continue working with this event, don't clean up the resources created in this article. Otherwise, use the following command to delete the resources you created in this article.
121+
122+
If you plan to continue working with this event, don't clean up the resources that you created in this article. Otherwise, use the following command to delete the resources:
121123

122124
```azurecli-interactive
123125
az group delete --name gridResourceGroup
124126
```
125127

126-
## Next steps
128+
## Related content
127129

128130
Now that you know how to create topics and event subscriptions, learn more about what Event Grid can help you do:
129131

130132
- [About Event Grid](overview.md)
131-
- [Route Blob storage events to a custom web endpoint](../storage/blobs/storage-blob-event-quickstart.md?toc=%2fazure%2fevent-grid%2ftoc.json)
133+
- [Route Azure Blob Storage events to a custom web endpoint](../storage/blobs/storage-blob-event-quickstart.md?toc=%2fazure%2fevent-grid%2ftoc.json)
132134
- [Monitor virtual machine changes with Azure Event Grid and Logic Apps](monitor-virtual-machine-changes-logic-app.md)
133135
- [Stream big data into a data warehouse](event-hubs-integration.md)
134136

135-
See the following samples to learn about publishing events to and consuming events from Event Grid using different programming languages.
137+
To learn about publishing events to, and consuming events from, Event Grid by using various programming languages, see the following samples:
136138

137139
- [Azure Event Grid samples for .NET](/samples/azure/azure-sdk-for-net/azure-event-grid-sdk-samples/)
138140
- [Azure Event Grid samples for Java](/samples/azure/azure-sdk-for-java/eventgrid-samples/)

0 commit comments

Comments
 (0)