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/azure-functions/event-grid-how-tos.md
+28-28Lines changed: 28 additions & 28 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: How to work with Event Grid triggers and bindings in Azure Functions
3
3
description: Contains various procedures for integrating Azure Event Grid and Azure Functions using triggers and bindings.
4
-
ms.date: 10/12/2021
4
+
ms.date: 08/07/2024
5
5
ms.topic: how-to
6
6
ms.service: azure-functions
7
7
@@ -15,21 +15,21 @@ Azure Functions provides built-in integration with Azure Event Grid by using [tr
15
15
+[Azure Event Grid trigger for Azure Functions](functions-bindings-event-grid-trigger.md)
16
16
+[Azure Event Grid output binding for Azure Functions](functions-bindings-event-grid-output.md)
17
17
18
-
## Event subscriptions
18
+
## Create an event subscription
19
19
20
20
To start receiving Event Grid HTTP requests, you need a subscription to events raised by Event Grid. Event subscriptions specify the endpoint URL that invokes the function. When you create an event subscription from your function's **Integration** tab in the [Azure portal](https://portal.azure.com), the URL is supplied for you. When you programmatically create an event subscription or when you create the event subscription from Event Grid, you'll need to provide the endpoint. The endpoint URL contains a system key, which you must obtain from Functions administrator REST APIs.
21
21
22
-
### Webhook endpoint URL
22
+
##Get the webhook endpoint URL
23
23
24
24
The URL endpoint for your Event Grid triggered function depends on the version of the Functions runtime. The following example shows the version-specific URL pattern:
>There is a version of the Blob storage trigger that also uses event subscriptions. The endpoint URL for this kind of Blob storage trigger has a path of `/runtime/webhooks/blobs`, whereas the path for an Event Grid trigger would be `/runtime/webhooks/EventGrid`. For a comparison of options for processing blobs, see [Trigger on a blob container](storage-considerations.md#trigger-on-a-blob-container).
41
41
42
-
### System key
42
+
##Obtain the system key
43
43
44
-
The URL endpoint you construct includes the system key value. The system key is an authorization key that has to be included in the endpoint URL for an Event Grid trigger. The following section explains how to get the system key.
44
+
The URL endpoint you construct includes a system key value. The system key is an authorization key, specific to the Event Grid webhook, that must be included in a request to the endpoint URL for an Event Grid trigger. The following section explains how to get the system key.
45
45
46
-
You can get the system key by using the following API (HTTP GET):
46
+
You can also get the master key for your function app from **Functions** > **App keys** in the portal.
47
47
48
-
#### [v2.x+](#tab/v2)
48
+
> [!CAUTION]
49
+
> The master key provides administrator access to your function app. Don't share this key with third parties or distribute it in native client applications.
50
+
51
+
For more information, see [Work with access keys in Azure Functions](function-keys-how-to.md).
52
+
53
+
You can get the system key from your function app by using the following administrator APIs (HTTP GET):
This REST API is an administrator API, so it requires your function app [master key](function-keys-how-to.md). Don't confuse the system key (for invoking an Event Grid trigger function) with the master key (for performing administrative tasks on the function app). When you subscribe to an Event Grid topic, be sure to use the system key.
69
+
This REST API is an administrator API, so it requires your function app [master key](function-keys-how-to.md). Don't confuse the system key (for invoking an Event Grid trigger function) with the master key (for performing administrative tasks on the function app). When you subscribe to an Event Grid topic, be sure to use the system key.
63
70
64
71
Here's an example of the response that provides the system key:
65
72
@@ -76,18 +83,11 @@ Here's an example of the response that provides the system key:
76
83
}
77
84
```
78
85
79
-
You can get the master key for your function app from the **Function app settings** tab in the portal.
80
-
81
-
> [!IMPORTANT]
82
-
> The master key provides administrator access to your function app. Don't share this key with third parties or distribute it in native client applications.
83
-
84
-
For more information, see [Authorization keys](functions-bindings-http-webhook-trigger.md#authorization-keys) in the HTTP trigger reference article.
85
-
86
-
### <aname="create-a-subscription"></a>Create an event subscription
86
+
## <aname="create-a-subscription"></a>Create an event subscription
87
87
88
88
You can create an event subscription either from the [Azure portal](https://portal.azure.com) or by using the Azure CLI.
89
89
90
-
####[Portal](#tab/portal)
90
+
### [Portal](#tab/portal)
91
91
92
92
For functions that you develop in the Azure portal with the Event Grid trigger, select **Integration** then choose the **Event Grid Trigger** and select **Create Event Grid subscription**.
93
93
@@ -99,7 +99,7 @@ When you select this link, the portal opens the **Create Event Subscription** pa
99
99
100
100
For more information about how to create subscriptions by using the Azure portal, see [Create custom event - Azure portal](../event-grid/custom-event-quickstart-portal.md) in the Event Grid documentation.
101
101
102
-
####[Azure CLI](#tab/azure-cli)
102
+
### [Azure CLI](#tab/azure-cli)
103
103
104
104
To create a subscription by using [the Azure CLI](/cli/azure/get-started-with-azure-cli), use the [`az eventgrid event-subscription create`](/cli/azure/eventgrid/event-subscription#az-eventgrid-event-subscription-create) command. Examples use the v2.x+ version of the URL and are written to run in [Azure Cloud Shell](../cloud-shell/overview.md). You'll need to modify the examples to run from a Windows command prompt.
105
105
@@ -133,7 +133,7 @@ To send an HTTP post request, you need an HTTP test tool, like one of these:
133
133
134
134
When you're done testing, you can use the same subscription for production by updating the endpoint. Use the [`az eventgrid event-subscription update`](/cli/azure/eventgrid/event-subscription#az-eventgrid-event-subscription-update) Azure CLI command.
135
135
136
-
###Create a viewer web app
136
+
## Create a viewer web app
137
137
138
138
To simplify capturing event messages, you can 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.
139
139
@@ -148,21 +148,21 @@ You see the site but no events have been posted to it yet.
148
148
149
149

150
150
151
-
###Create an Event Grid subscription
151
+
## Create an Event Grid subscription
152
152
153
153
Create an Event Grid subscription of the type you want to test, and give it the URL from your web app as the endpoint for event notification. The endpoint for your web app must include the suffix `/api/updates/`. So, the full URL is `https://<your-site-name>.azurewebsites.net/api/updates`
154
154
155
155
For information about how to create subscriptions by using the Azure portal, see [Create custom event - Azure portal](../event-grid/custom-event-quickstart-portal.md) in the Event Grid documentation.
156
156
157
-
###Generate a request
157
+
## Generate a request
158
158
159
159
Trigger an event that will generate HTTP traffic to your web app endpoint. For example, if you created a blob storage subscription, upload or delete a blob. When a request shows up in your web app, copy the request body.
160
160
161
161
The subscription validation request will be received first; ignore any validation requests, and copy the event request.
162
162
163
163

164
164
165
-
###Manually post the request
165
+
## Manually post the request
166
166
167
167
Run your Event Grid function locally. The `Content-Type` and `aeg-event-type` headers are required to be manually set, while and all other values can be left as default.
168
168
@@ -173,13 +173,13 @@ Use your HTTP test tool to create an HTTP POST request:
173
173
* Paste the RequestBin data into the request body.
174
174
* Send an HTTP POST request to the endpoint that manually starts the Event Grid trigger.
0 commit comments