Skip to content

Commit 6727589

Browse files
Merge pull request #262848 from spelluru/egridfresh0104
Event Grid freshness
2 parents ea32682 + e26abcd commit 6727589

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

articles/event-grid/custom-event-quickstart.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Quickstart: Send custom events with Event Grid and Azure CLI'
33
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: 10/28/2022
4+
ms.date: 01/05/2024
55
ms.topic: quickstart
66
ms.custom: devx-track-azurecli, mode-api
77
---
@@ -25,7 +25,7 @@ When you're finished, you see that the event data has been sent to the web app.
2525

2626
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.
2727

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.
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 select **Try it**, you'll see the Azure Cloud Shell window in the right pane. Then, select **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.
2929

3030
```azurecli-interactive
3131
az group create --name gridResourceGroup --location westus2
@@ -35,7 +35,7 @@ az group create --name gridResourceGroup --location westus2
3535

3636
## Create a custom topic
3737

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 "-"
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 Domain Name System (DNS) entry. Additionally, it must be between 3-50 characters and contain only values a-z, A-Z, 0-9, and "-"
3939

4040
1. Copy the following command, specify a name for the topic, and press ENTER to run the command.
4141

@@ -50,7 +50,7 @@ An Event Grid topic provides a user-defined endpoint that you post your events t
5050
5151
## Create a message endpoint
5252
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.
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 [prebuilt 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.
5454
5555
5656
@@ -68,7 +68,7 @@ Before subscribing to the custom topic, let's create the endpoint for the event
6868
--parameters siteName=$sitename hostingPlanName=viewerhost
6969
```
7070
71-
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:
71+
The deployment might 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:
7272
`https://<your-site-name>.azurewebsites.net`
7373
7474
You should see the site with no messages currently displayed.
@@ -79,19 +79,27 @@ You subscribe to an Event Grid topic to tell Event Grid which events you want to
7979
8080
The endpoint for your web app must include the suffix `/api/updates/`.
8181
82-
```azurecli-interactive
83-
endpoint=https://$sitename.azurewebsites.net/api/updates
84-
85-
az eventgrid event-subscription create \
86-
--source-resource-id "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/topics/$topicname" \
87-
--name demoViewerSub \
88-
--endpoint $endpoint
89-
90-
```
82+
1. Copy the following command, replace `$sitename` with the name of the web app you created in the previous step, and press ENTER to run the command.
9183
92-
View your web app again, and notice that a subscription validation event has been sent to it. Select the eye icon to expand the event data. Event Grid sends the validation event so the endpoint can verify that it wants to receive event data. The web app includes code to validate the subscription.
84+
```azurecli-interactive
85+
endpoint=https://$sitename.azurewebsites.net/api/updates
86+
```
87+
2. Run the following command to get the resource ID of the topic you created.
88+
89+
```azurecli-interactive
90+
topicresourceid=$(az eventgrid topic show --resource-group gridResourceGroup --name $topicname --query "id" --output tsv)
91+
```
92+
3. Run the following command to create a subscription to the custom topic using the endpoint.
93+
```azurecli-interactive
94+
az eventgrid event-subscription create \
95+
--source-resource-id $topicresourceid \
96+
--name demoViewerSub \
97+
--endpoint $endpoint
98+
```
9399
94-
![View the subscription event in Azure Event Grid Viewer](./media/custom-event-quickstart/viewer-subscription-validation-event.png)
100+
View your web app again, and notice that a subscription validation event has been sent to it. Select the eye icon to expand the event data. Event Grid sends the validation event so the endpoint can verify that it wants to receive event data. The web app includes code to validate the subscription.
101+
102+
![View the subscription event in Azure Event Grid Viewer](./media/custom-event-quickstart/viewer-subscription-validation-event.png)
95103
96104
97105
## Send an event to your custom topic

0 commit comments

Comments
 (0)