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/includes/register-provider-cli.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,20 @@
4
4
author: spelluru
5
5
ms.service: azure-event-grid
6
6
ms.topic: include
7
-
ms.date: 08/17/2018
7
+
ms.date: 06/23/2025
8
8
ms.author: spelluru
9
9
ms.custom: include file
10
10
---
11
11
12
12
## Enable the Event Grid resource provider
13
13
14
-
1. If you haven't previously used Event Grid in your Azure subscription, you might need to register the Event Grid resource provider. Run the following command to register the provider:
14
+
1. If this is the first time you're using Event Grid in your Azure subscription, you might need to register the Event Grid resource provider. Run the following command to register the provider:
15
15
16
16
```azurecli-interactive
17
17
az provider register --namespace Microsoft.EventGrid
18
18
```
19
19
20
-
2. It might take a moment for the registration to finish. To check the status, run the following command:
20
+
1. It might take a moment for the registration to finish. To check the status, run the following command:
21
21
22
22
```azurecli-interactive
23
23
az provider show --namespace Microsoft.EventGrid --query "registrationState"
title: Publish and consume events using namespace topics
3
-
description: This article provides step-by-step instructions to publish events to Azure Event Grid in the CloudEvents JSON format and consume those events by using the pull delivery model.
2
+
title: "Quickstart: Publish and Consume Events Using Namespace Topics"
3
+
description: Learn how to publish events to Azure Event Grid in the CloudEvents JSON format and consume those events by using the pull delivery model.
#customer intent: As a developer, I want to use the pull delivery model to publish and consume events using Azure Event Grid.
9
10
---
10
11
11
-
# Publish to namespace topics and consume events in Azure Event Grid
12
+
# Quickstart: Publish to namespace topics and consume events in Azure Event Grid
12
13
13
-
This article provides a quick introduction to pull delivery using the ``curl`` bash shell command to publish, receive, and acknowledge events. Event Grid resources are created using CLI commands. This article is suitable for a quick test of the pull delivery functionality. For sample code using the data plane SDKs, see the [.NET](event-grid-dotnet-get-started-pull-delivery.md) or the Java samples. For Java, we provide the sample code in two articles: [publish events](publish-events-to-namespace-topics-java.md) and [receive events](receive-events-from-namespace-topics-java.md) quickstarts.
14
-
For more information about the pull delivery model, see the [concepts](concepts-event-grid-namespaces.md) and [pull delivery overview](pull-delivery-overview.md) articles.
14
+
In this quickstart, you do pull delivery using the `curl` bash shell command to publish, receive, and acknowledge events. Use Azure CLI commands to create Azure Event Grid resources. This article is suitable for a quick test of the pull delivery functionality.
15
+
16
+
For sample code that uses the data plane SDKs, see these resources:
17
+
18
+
- .NET: [Send and receive messages from an Azure Event Grid namespace topic (.NET)](event-grid-dotnet-get-started-pull-delivery.md)
19
+
- Java: [Publish events to namespace topics using Java](publish-events-to-namespace-topics-java.md)
20
+
- Java: [Receive events using pull delivery with Java](receive-events-from-namespace-topics-java.md)
21
+
22
+
For more information about the pull delivery model, see [Azure Event Grid namespace concepts](concepts-event-grid-namespaces.md) and [Pull delivery with HTTP](pull-delivery-overview.md) articles.
- This article requires version 2.0.70 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
28
+
- This article requires version 2.0.70 or later of the Azure CLI. If you use Azure Cloud Shell, the latest version is already installed.
21
29
22
30
## Create a resource group
23
-
Create an Azure resource group with the [az group create](/cli/azure/group#az-group-create) command. You use this resource group to contain all resources created in this article.
31
+
32
+
Create an Azure resource group with the [az group create](/cli/azure/group#az-group-create) command. Use this resource group to contain all resources you create in this article.
24
33
25
34
The general steps to use Cloud Shell to run commands are:
26
35
27
36
- Select **Open Cloud Shell** to see an Azure Cloud Shell window on the right pane.
28
37
- Copy the command and paste into the Azure Cloud Shell window.
29
38
- Press ENTER to run the command.
30
39
31
-
1. Declare a variable to hold the name of an Azure resource group. Specify a name for the resource group by replacing `<your-resource-group-name>` with a value you like.
40
+
1. Declare a variable to hold the name of an Azure resource group. Specify a name for the resource group by replacing `<your-resource-group-name>` with your value.
32
41
33
42
```azurecli-interactive
34
43
resource_group="<your-resource-group-name>"
35
44
```
36
-
2. Create a resource group. Change the location as you see fit.
45
+
46
+
1. Create a resource group. You can change the location to any Azure location.
37
47
38
48
```azurecli-interactive
39
49
az group create --name $resource_group --location eastus
@@ -47,131 +57,143 @@ An Event Grid namespace provides a user-defined endpoint to which you post your
47
57
48
58
- It should be between 3-50 characters.
49
59
- It should be regionally unique.
50
-
- Only allowed characters are a-z, A-Z, 0-9 and -
51
-
- It shouldn't start with reserved key word prefixes like `Microsoft`, `System` or `EventGrid`.
60
+
- Only allowed characters are: a-z, A-Z, 0-9, and -
61
+
- It shouldn't start with reserved key word prefixes like `Microsoft`, `System`, or `EventGrid`.
52
62
53
-
1. Declare a variable to hold the name for your Event Grid namespace. Specify a name for the namespace by replacing `<your-namespace-name>` with a value you like.
63
+
1. Declare a variable to hold the name for your Event Grid namespace. Specify a name for the namespace by replacing `<your-namespace-name>` with your value.
54
64
55
-
```azurecli-interactive
56
-
namespace="<your-namespace-name>"
57
-
```
58
-
2. Create a namespace. You might want to change the location where it's deployed.
65
+
```azurecli-interactive
66
+
namespace="<your-namespace-name>"
67
+
```
59
68
60
-
```azurecli-interactive
61
-
az eventgrid namespace create -g $resource_group -n $namespace -l eastus
62
-
```
69
+
1. Create a namespace. You might want to change the location where you deploy it.
70
+
71
+
```azurecli-interactive
72
+
az eventgrid namespace create --resource-group $resource_group --name $namespace --location eastus
73
+
```
63
74
64
75
## Create a namespace topic
65
76
66
-
Create a topic that's used to hold all events published to the namespace endpoint.
77
+
Create a topic that holds all events published to the namespace endpoint.
67
78
68
-
1. Declare a variable to hold the name for your namespace topic. Specify a name for the namespace topic by replacing `<your-topic-name>` with a value you like.
79
+
1. Declare a variable to hold the name for your namespace topic. Specify a name for the namespace topic by replacing `<your-topic-name>` with your value.
Create an event subscription setting its delivery mode to *queue*, which supports [pull delivery](pull-delivery-overview.md). For more information on all configuration options,see the latest Event Grid control plane [REST API](/rest/api/eventgrid).
93
+
Create an event subscription setting its delivery mode to *queue*, which supports [pull delivery](pull-delivery-overview.md). For more information on all configuration options,see [Azure Event Grid REST API](/rest/api/eventgrid).
82
94
83
-
1. Declare a variable to hold the name for an event subscription to your namespace topic. Specify a name for the event subscription by replacing `<your-event-subscription-name>` with a value you like.
95
+
1. Declare a variable to hold the name for an event subscription to your namespace topic. Specify a name for the event subscription by replacing `<your-event-subscription-name>` with your value.
Now, send a sample event to the namespace topic by following steps in this section.
108
+
109
+
Send a sample event to the namespace topic by following steps in this section.
96
110
97
111
### List namespace access keys
98
112
99
-
1. Get the access keys associated with the namespace you created. You use one of them to authenticate when publishing events. To list your keys, you need the full namespace resource ID first. Get it by running the following command:
113
+
1. Get the access keys associated with the namespace you created. You need one of them to authenticate when publishing events. To list your keys, get the full namespace resource ID. Run the following command:
1. Retrieve the namespace hostname. You use it to compose the namespace HTTP endpoint to which events are sent. The following operations were first available with API version `2023-06-01-preview`.
1. Create a sample [CloudEvents](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md) compliant event:
122
134
123
-
The `data` element is the payload of your event. Any well-formed JSON can go in this field. For more information on properties (also known as context attributes) that can go in an event, see the [CloudEvents](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md) specifications.
124
-
3. Use CURL to send the event to the topic. CURL is a utility that sends HTTP requests.
The `data` element is the payload of your event. Any well-formed JSON can go in this field. Properties that can go into an event are also known as *context attributes*. For more information, see [CloudEvents](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md).
140
+
141
+
1. Use CURL to send the event to the topic. CURL is a utility that sends HTTP requests.
curl -X POST -H "Content-Type: application/json" -H "Authorization:SharedAccessKey $key" $receive_operation_uri
143
-
```
157
+
1. Submit a request to consume the event:
158
+
159
+
```azurecli-interactive
160
+
curl -X POST -H "Content-Type: application/json" -H "Authorization:SharedAccessKey $key" $receive_operation_uri
161
+
```
144
162
145
163
### Acknowledge an event
146
164
147
-
After you receive an event, you pass that event to your application for processing. Once you have successfully processed your event, you no longer need that event to be in your event subscription. To instruct Event Grid to delete the event, you **acknowledge** it using its lock token that you got on the receive operation's response.
165
+
After you receive an event, you pass that event to your application for processing. After you successfully process your event, you no longer need that event to be in your event subscription. To instruct Event Grid to delete the event, you **acknowledge** it using its lock token that you got on the receive operation's response.
148
166
149
-
1. In the previous step, you should have received a response that includes a `brokerProperties` object with a `lockToken` property. Copy the lock token value and set it on an environment variable:
167
+
1. In the previous section, you received a response that includes a `brokerProperties` object with a `lockToken` property. Copy the lock token value and set it on an environment variable:
150
168
151
-
```azurecli-interactive
152
-
lockToken="<paste-the-lock-token-here>"
153
-
```
154
-
2. Now, build the acknowledge operation payload, which specifies the lock token for the event you want to be acknowledged.
If the acknowledge operation is executed before the lock token expires (300 seconds as set when we created the event subscription), you should see a response like the following example:
If the acknowledge operation is executed before the lock token expires (300 seconds as set when we created the event subscription), you should see a response like the following example:
0 commit comments