You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/event-grid/custom-event-quickstart.md
+27-19Lines changed: 27 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: 'Quickstart: Send custom events with Event Grid and Azure CLI'
3
3
description: 'Quickstart Use Azure Event Grid and Azure CLI to publish a custom topic, and subscribe to events for that topic. The events are handled by a web application.'
4
-
ms.date: 07/01/2021
4
+
ms.date: 10/28/2022
5
5
ms.topic: quickstart
6
6
ms.custom: devx-track-azurecli, mode-api
7
7
---
@@ -13,7 +13,7 @@ Typically, you send events to an endpoint that processes the event data and take
13
13
14
14
When you're finished, you see that the event data has been sent to the web app.
15
15
16
-

16
+
:::image type="content" source="./media/custom-event-quickstart/azure-event-grid-viewer-record-inserted-event.png" alt-text="Screenshot showing the Event Grid Viewer sample with a sample event.":::
@@ -25,9 +25,7 @@ When you're finished, you see that the event data has been sent to the web app.
25
25
26
26
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.
27
27
28
-
Create a resource group with the [az group create](/cli/azure/group#az-group-create) command.
29
-
30
-
The following example creates a resource group named *gridResourceGroup* in the *westus2* location.
28
+
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. If you click **Try it**, you'll see the Azure Cloud Shell window in the right pane. Then, click **Copy** to copy the command and paste it in the Azure Cloud Shell window, and press ENTER to run the command. Change the name of the resource group and the location if you like.
31
29
32
30
```azurecli-interactive
33
31
az group create --name gridResourceGroup --location westus2
@@ -37,28 +35,38 @@ az group create --name gridResourceGroup --location westus2
37
35
38
36
## Create a custom topic
39
37
40
-
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 using Bash in Azure Cloud Shell. Replace `<your-topic-name>` with a unique name for your topic. The custom topic name must be unique because it's part of the DNS entry. Additionally, it must be between 3-50 characters and contain only values a-z, A-Z, 0-9, and "-"
38
+
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 using Bash in Azure Cloud Shell. Replace `<your-topic-name>` with a unique name for your topic. The custom topic name must be unique because it's part of the DNS entry. Additionally, it must be between 3-50 characters and contain only values a-z, A-Z, 0-9, and "-"
41
39
42
-
```azurecli-interactive
43
-
topicname=<your-topic-name>
40
+
1. Copy the following command, specify a name for the topic, and press ENTER to run the command.
44
41
45
-
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
46
-
```
42
+
```azurecli-interactive
43
+
topicname=<your-topic-name>
44
+
```
45
+
2. Use the [`az eventgrid topic create`](/cli/azure/eventgrid/topic#az-eventgrid-topic-create) command to create a custom topic.
46
+
47
+
```azurecli-interactive
48
+
az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup
49
+
```
47
50
48
51
## Create a message endpoint
49
52
50
53
Before subscribing to the custom topic, let's create the endpoint for the event message. Typically, the endpoint takes actions based on the event data. To simplify this quickstart, you deploy a [pre-built web app](https://github.com/Azure-Samples/azure-event-grid-viewer) that displays the event messages. The deployed solution includes an App Service plan, an App Service web app, and source code from GitHub.
51
54
52
-
Replace `<your-site-name>` with a unique name for your web app. The web app name must be unique because it's part of the DNS entry.
1. Copy the following command, specify a name for the web app (Event Grid Viewer sample), and press ENTER to run the command. Replace `<your-site-name>` with a unique name for your web app. The web app name must be unique because it's part of the DNS entry.
58
+
59
+
```azurecli-interactive
60
+
sitename=<your-site-name>
61
+
```
62
+
2. Run the [`az deployment group create`](/cli/azure/deployment/group#az-deployment-group-create) to deploy the web app using an Azure Resource Manager template.
The deployment may take a few minutes to complete. After the deployment has succeeded, view your web app to make sure it's running. In a web browser, navigate to:
64
72
`https://<your-site-name>.azurewebsites.net`
@@ -67,7 +75,7 @@ You should see the site with no messages currently displayed.
67
75
68
76
## Subscribe to a custom topic
69
77
70
-
You subscribe to an event grid topic to tell Event Grid which events you want to track and where to send those events. The following example subscribes to the custom topic you created, and passes the URL from your web app as the endpoint for event notification.
78
+
You subscribe to an Event Grid topic to tell Event Grid which events you want to track and where to send those events. The following example subscribes to the custom topic you created, and passes the URL from your web app as the endpoint for event notification.
71
79
72
80
The endpoint for your web app must include the suffix `/api/updates/`.
0 commit comments