Skip to content

Commit a487627

Browse files
committed
Custom event - Queue storage - review & update
1 parent ec3f987 commit a487627

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

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

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
---
22
title: 'Quickstart: Send custom events to storage queue - Event Grid, Azure CLI'
33
description: 'Quickstart: Use Azure Event Grid and Azure CLI to publish a topic, and subscribe to that event. A storage queue is used for the endpoint.'
4-
ms.date: 02/02/2021
4+
ms.date: 11/17/2022
55
ms.topic: quickstart
66
ms.custom: devx-track-azurecli, mode-api
77
---
88

9-
# Quickstart: Route custom events to Azure Queue storage with Azure CLI and Event Grid
9+
# Quickstart: Route custom events to Azure Queue storage via Event Grid using Azure CLI
1010

11-
Azure Event Grid is an eventing service for the cloud. Azure Queue storage 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 the Queue storage.
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 Queue storage 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 Queue subscription for the custom topic.
15+
1. Send sample events to the custom topic.
16+
1. Verify that those events are delivered to Azure Queue storage.
1217

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

1520
[!INCLUDE [azure-cli-prepare-your-environment.md](../../includes/azure-cli-prepare-your-environment.md)]
1621

17-
- This article requires version 2.0.56 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
18-
19-
- If you are using Azure PowerShell on your local machine instead of using Cloud Shell in the Azure portal, ensure that you have Azure PowerShell version 1.1.0 or greater. Download the latest version of Azure PowerShell on your Windows machine from [Azure downloads - Command-line tools](https://azure.microsoft.com/downloads/).
20-
21-
This article gives you commands for using Azure CLI.
22-
2322
## Create a resource group
2423

2524
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.
2625

27-
Create a resource group with the [az group create](/cli/azure/group#az-group-create) command.
28-
29-
The following example creates a resource group named *gridResourceGroup* in the *westus2* location.
26+
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.
3027

3128
```azurecli-interactive
3229
az group create --name gridResourceGroup --location westus2
@@ -38,27 +35,40 @@ az group create --name gridResourceGroup --location westus2
3835

3936
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.
4037

38+
1. Specify a name for the topic.
39+
40+
```azurecli-interactive
41+
topicname="<TOPIC NAME>"
42+
```
43+
1. Run the following command to create the topic.
44+
4145
```azurecli-interactive
42-
az eventgrid topic create --name <topic_name> -l westus2 -g gridResourceGroup
46+
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
4347
```
4448

4549
## Create Queue storage
4650

4751
Before subscribing to the custom topic, let's create the endpoint for the event message. You create a Queue storage for collecting the events.
4852

49-
```azurecli-interactive
50-
storagename="<unique-storage-name>"
51-
queuename="eventqueue"
53+
1. Specify a unique name for the Azure Storage account.
5254

53-
az storage account create -n $storagename -g gridResourceGroup -l westus2 --sku Standard_LRS
54-
az storage queue create --name $queuename --account-name $storagename
55-
```
55+
```azurecli-interactive
56+
storagename="<STORAGE ACCOUNT NAME>"
57+
```
58+
1. Run the following commands to create an Azure Storage account and a queue (named `eventqueue`) in the storage.
59+
60+
```azurecli-interactive
61+
queuename="eventqueue"
62+
63+
az storage account create -n $storagename -g gridResourceGroup -l westus2 --sku Standard_LRS
64+
az storage queue create --name $queuename --account-name $storagename
65+
```
5666
5767
## Subscribe to a custom topic
5868
59-
You subscribe to a custom 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 Queue storage for the endpoint. With Azure CLI, you pass the Queue storage ID as the endpoint. The endpoint is in the format:
69+
The following example subscribes to the custom topic you created, and passes the resource ID of the Queue storage for the endpoint. With Azure CLI, you pass the Queue storage ID as the endpoint. The endpoint is in the format:
6070
61-
`/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-name>/queueservices/default/queues/<queue-name>`
71+
`/subscriptions/<AZURE SUBSCRIPTION ID>/resourcegroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>/queueservices/default/queues/<QUEUE NAME>`
6272
6373
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.
6474
@@ -91,14 +101,14 @@ If you use the REST API to create the subscription, you pass the ID of the stora
91101

92102
## Send an event to your custom topic
93103

94-
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. Again, use your custom topic name for `<topic_name>`.
104+
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.
95105

96106
```azurecli-interactive
97-
endpoint=$(az eventgrid topic show --name <topic_name> -g gridResourceGroup --query "endpoint" --output tsv)
98-
key=$(az eventgrid topic key list --name <topic_name> -g gridResourceGroup --query "key1" --output tsv)
107+
endpoint=$(az eventgrid topic show --name $topicname -g gridResourceGroup --query "endpoint" --output tsv)
108+
key=$(az eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv)
99109
```
100110

101-
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:
111+
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:
102112

103113
```azurecli-interactive
104114
for i in 1 2 3

0 commit comments

Comments
 (0)