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/post-to-custom-topic.md
+81-5Lines changed: 81 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
title: Post event to custom Azure Event Grid topic
3
-
description: This article describes how to post an event to a custom topic. It shows the format of the post and event data.
3
+
description: This article describes how to post an event to a custom topic using Azure PowerShell or Azure CLI. It shows the format of the post and event data.
4
4
ms.topic: conceptual
5
-
ms.date: 01/18/2024
5
+
ms.date: 06/18/2024
6
6
---
7
7
8
-
# Publish events to Azure Event Grid custom topics using access keys
8
+
# Publish events to Azure Event Grid custom topics using access keys using PowerShell and CLI
9
9
10
10
This article describes how to post an event to a custom topic using an access key. It shows the format of the post and event data. The [Service Level Agreement (SLA)](https://azure.microsoft.com/support/legal/sla/event-grid/v1_0/) only applies to posts that match the expected format.
11
11
@@ -17,30 +17,48 @@ This article describes how to post an event to a custom topic using an access ke
17
17
18
18
When sending the HTTP POST to a custom topic, use the URI format: `https://<topic-endpoint>?api-version=2018-01-01`. For example, a valid URI is: `https://exampletopic.westus2-1.eventgrid.azure.net/api/events?api-version=2018-01-01`. To get the endpoint for a custom topic using Azure CLI, use:
19
19
20
+
# [Azure portal](#tab/azure-portal)
21
+
You can find the topic's endpoint on the **Overview** tab of the **Event Grid Topic** page in the Azure portal.
22
+
23
+
:::image type="content" source="./media/post-to-custom-topic/topic-endpoint.png" alt-text="Screenshot that shows the Event Grid Topic page on the Azure portal with the topic endpoint highlighted." lightbox="./media/post-to-custom-topic/topic-endpoint.png":::
24
+
25
+
# [Azure CLI](#tab/azure-cli)
26
+
20
27
```azurecli-interactive
21
28
az eventgrid topic show --name <topic-name> -g <topic-resource-group> --query "endpoint"
22
29
```
23
30
24
-
To get the endpoint for a custom topic using Azure PowerShell, use:
In the request, include a header value named `aeg-sas-key` that contains a key for authentication. For example, a valid header value is `aeg-sas-key: xxxxxxxxxxxxxxxxxxxxxxx`. To get the key for a custom topic using Azure CLI, use:
33
42
43
+
# [Azure portal](#tab/azure-portal)
44
+
To get the access key for the custom topic, select **Access keys** tab on the **Event Grid Topic** page in the Azure portal.
45
+
46
+
:::image type="content" source="./media/post-to-custom-topic/custom-topic-access-keys.png" alt-text="Screenshot that shows the Access Keys tab of the Event Grid Topic page on the Azure portal." lightbox="./media/post-to-custom-topic/custom-topic-access-keys.png":::
47
+
48
+
# [Azure CLI](#tab/azure-cli)
49
+
34
50
```azurecli
35
51
az eventgrid topic key list --name <topic-name> -g <topic-resource-group> --query "key1"
36
52
```
37
53
38
-
To get the key for a custom topic using PowerShell, use:
For custom topics, the top-level data contains the same fields as standard resource-defined events. One of those properties is a `data` property that contains properties unique to the custom topic. As an event publisher, you determine properties for that data object. Here's the schema:
@@ -78,6 +96,64 @@ For example, a valid event data schema is:
78
96
}]
79
97
```
80
98
99
+
## Send the sample event
100
+
101
+
# [Azure portal](#tab/azure-portal)
102
+
103
+
1. In the [Azure portal](https://portal.azure.com), launch Cloud Shell.
104
+
1. In the Cloud Shell, run the commands from the Azure PowerShell or Azure CLI in the **Bash** or **PowerShell** session.
105
+
106
+
:::image type="content" source="./media/post-to-custom-topic/cloud-shell.png" alt-text="Screenshot that shows the Cloud Shell in the Azure portal." lightbox="./media/post-to-custom-topic/cloud-shell.png":::
107
+
108
+
109
+
# [Azure CLI](#tab/azure-cli)
110
+
111
+
```azurecli
112
+
endpoint=$(az eventgrid topic show --name <topic name> -g <resource group name> --query "endpoint" --output tsv)
113
+
114
+
key=$(az eventgrid topic key list --name <topic name> -g <resource group name> --query "key1" --output tsv)
0 commit comments