Skip to content

Commit 633006a

Browse files
authored
Merge pull request #219008 from spelluru/egridehub11118
update event grid - event hubs quickstart
2 parents ddfeef2 + 8905973 commit 633006a

File tree

2 files changed

+46
-29
lines changed

2 files changed

+46
-29
lines changed

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

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,78 @@
11
---
22
title: 'Quickstart: Send custom events to Event Hubs - Event Grid, Azure CLI'
33
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.'
4-
ms.date: 09/28/2021
4+
ms.date: 11/18/2022
55
ms.topic: quickstart
66
ms.custom: devx-track-azurecli, mode-api
77
---
88

99
# Quickstart: Route custom events to Azure Event Hubs with Azure CLI and Event Grid
1010

11-
Azure Event Grid is an eventing service for the cloud. Azure Event Hubs is one of the supported event handlers. In this article, you use the Azure CLI to create a custom topic, subscribe to the custom topic, and trigger the event to view the result. You send the events to an event hub.
11+
[Azure Event Grid](overview.md) is a highly scalable and serverless event broker that you can use to integrate applications using events. Events are delivered by Event Grid 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:
12+
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.
1217

1318
[!INCLUDE [quickstarts-free-trial-note.md](../../includes/quickstarts-free-trial-note.md)]
1419

1520
## Create a resource group
1621

1722
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.
1823

19-
Create a resource group with the [az group create](/cli/azure/group#az-group-create) command.
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.
2025

21-
The following example creates a resource group named *gridResourceGroup* in the *westus2* location.
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.
2228
2329
```azurecli-interactive
2430
az group create --name gridResourceGroup --location westus2
2531
```
2632

2733
[!INCLUDE [event-grid-register-provider-cli.md](../../includes/event-grid-register-provider-cli.md)]
2834

29-
## Create a Custom Topic
35+
## Create a custom topic
3036

31-
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 `<your-topic-name>` with a unique name for your custom topic. The custom topic name must be unique because it's represented by a DNS entry.
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 DNS entry.
3238

33-
```azurecli-interactive
34-
topicname=<your-topic-name>
35-
```
39+
1. Specify a name for the topic.
3640

37-
```azurecli-interactive
38-
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
39-
```
41+
```azurecli-interactive
42+
topicname="<TOPIC NAME>"
43+
```
44+
1. Run the following command to create the topic.
45+
46+
```azurecli-interactive
47+
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
48+
```
4049
41-
## Create event hub
50+
## Create an event hub
4251
4352
Before subscribing to the custom topic, let's create the endpoint for the event message. You create an event hub for collecting the events.
4453
45-
```azurecli-interactive
46-
namespace=<unique-namespace-name>
47-
```
54+
1. Specify a unique name for the Event Hubs namespace.
4855
49-
```azurecli-interactive
50-
hubname=demohub
56+
```azurecli-interactive
57+
namespace="<EVENT HUBS NAMESPACE NAME>"
58+
```
59+
1. Run the following commands to create an Event Hubs namespace and an event hub named `demohub` in that namespace.
5160
52-
az eventhubs namespace create --name $namespace --resource-group gridResourceGroup
53-
az eventhubs eventhub create --name $hubname --namespace-name $namespace --resource-group gridResourceGroup
54-
```
61+
62+
```azurecli-interactive
63+
hubname=demohub
64+
65+
az eventhubs namespace create --name $namespace --resource-group gridResourceGroup
66+
az eventhubs eventhub create --name $hubname --namespace-name $namespace --resource-group gridResourceGroup
67+
```
5568
5669
## Subscribe to a custom topic
5770
58-
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:
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:
5972
60-
`/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.EventHub/namespaces/<namespace-name>/eventhubs/<hub-name>`
73+
`/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.EventHub/namespaces/<NAMESPACE NAME>/eventhubs/<EVENT HUB NAME>`
6174
62-
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.
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.
6376
6477
```azurecli-interactive
6578
hubid=$(az eventhubs eventhub show --name $hubname --namespace-name $namespace --resource-group gridResourceGroup --query id --output tsv)
@@ -83,7 +96,7 @@ endpoint=$(az eventgrid topic show --name $topicname -g gridResourceGroup --quer
8396
key=$(az eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv)
8497
```
8598

86-
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:
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:
87100

88101
```azurecli-interactive
89102
for i in 1 2 3
@@ -93,7 +106,7 @@ do
93106
done
94107
```
95108

96-
Navigate to the event hub in the portal, and notice that Event Grid sent those three events to the event hub.
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'll see the same chart on the **Overview** page for the `demohub` Event Hubs instance page.
97110

98111
:::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.":::
99112

articles/event-grid/custom-event-to-queue-storage.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ az group create --name gridResourceGroup --location westus2
3434

3535
## Create a custom topic
3636

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 DNS entry.
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 DNS entry.
3838

3939
1. Specify a name for the topic.
4040

@@ -72,7 +72,11 @@ The following example subscribes to the custom topic you created, and passes the
7272
7373
`/subscriptions/<AZURE SUBSCRIPTION ID>/resourcegroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>/queueservices/default/queues/<QUEUE NAME>`
7474
75-
The following script gets the resource ID of the storage account for the queue. It constructs the ID for the queue storage, and subscribes to an event grid topic. It sets the endpoint type to `storagequeue` and uses the queue ID for the endpoint.
75+
The following script gets the resource ID of the storage account for the queue. It constructs the ID for the queue storage, and subscribes to an Event Grid topic. It sets the endpoint type to `storagequeue` and uses the queue ID for the endpoint.
76+
77+
78+
> [!IMPORTANT]
79+
> Replace expiration date placeholder (`<yyyy-mm-dd>`) with an actual value. For example: `2022-11-17` before running the command.
7680
7781
```azurecli-interactive
7882
storageid=$(az storage account show --name $storagename --resource-group gridResourceGroup --query id --output tsv)
@@ -110,7 +114,7 @@ endpoint=$(az eventgrid topic show --name $topicname -g gridResourceGroup --quer
110114
key=$(az eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv)
111115
```
112116

113-
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, you use CURL to send the event to the custom topic. The following example sends three events to the event grid topic:
117+
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, you use CURL to send the event to the custom topic. The following example sends three events to the Event Grid topic:
114118

115119
```azurecli-interactive
116120
for i in 1 2 3

0 commit comments

Comments
 (0)