Skip to content

Commit c4e2e2d

Browse files
authored
Update event-grid-how-tos.md
1 parent 82a4f49 commit c4e2e2d

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

articles/azure-functions/event-grid-how-tos.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: How to work with Event Grid triggers and bindings in Azure Functions
33
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
55
ms.topic: how-to
66
ms.service: azure-functions
77

@@ -15,21 +15,21 @@ Azure Functions provides built-in integration with Azure Event Grid by using [tr
1515
+ [Azure Event Grid trigger for Azure Functions](functions-bindings-event-grid-trigger.md)
1616
+ [Azure Event Grid output binding for Azure Functions](functions-bindings-event-grid-output.md)
1717

18-
## Event subscriptions
18+
## Create an event subscription
1919

2020
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.
2121

22-
### Webhook endpoint URL
22+
## Get the webhook endpoint URL
2323

2424
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:
2525

26-
#### [v2.x+](#tab/v2)
26+
### [v2.x+](#tab/v2)
2727

2828
```http
2929
https://{functionappname}.azurewebsites.net/runtime/webhooks/eventgrid?functionName={functionname}&code={systemkey}
3030
```
3131

32-
#### [v1.x](#tab/v1)
32+
### [v1.x](#tab/v1)
3333

3434
```http
3535
https://{functionappname}.azurewebsites.net/admin/extensions/EventGridExtensionConfig?functionName={functionname}&code={systemkey}
@@ -39,27 +39,34 @@ https://{functionappname}.azurewebsites.net/admin/extensions/EventGridExtensionC
3939
>[!NOTE]
4040
>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).
4141
42-
### System key
42+
## Obtain the system key
4343

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.
4545

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.
4747

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):
54+
55+
### [v2.x+](#tab/v2)
4956

5057
```
5158
http://{functionappname}.azurewebsites.net/admin/host/systemkeys/eventgrid_extension?code={masterkey}
5259
```
5360

54-
#### [v1.x](#tab/v1)
61+
### [v1.x](#tab/v1)
5562

5663
```
5764
http://{functionappname}.azurewebsites.net/admin/host/systemkeys/eventgridextensionconfig_extension?code={masterkey}
5865
```
5966

6067
---
6168

62-
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.
6370

6471
Here's an example of the response that provides the system key:
6572

@@ -76,18 +83,11 @@ Here's an example of the response that provides the system key:
7683
}
7784
```
7885

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-
### <a name="create-a-subscription"></a>Create an event subscription
86+
## <a name="create-a-subscription"></a>Create an event subscription
8787

8888
You can create an event subscription either from the [Azure portal](https://portal.azure.com) or by using the Azure CLI.
8989

90-
#### [Portal](#tab/portal)
90+
### [Portal](#tab/portal)
9191

9292
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**.
9393

@@ -99,7 +99,7 @@ When you select this link, the portal opens the **Create Event Subscription** pa
9999

100100
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.
101101

102-
#### [Azure CLI](#tab/azure-cli)
102+
### [Azure CLI](#tab/azure-cli)
103103

104104
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.
105105

@@ -133,7 +133,7 @@ To send an HTTP post request, you need an HTTP test tool, like one of these:
133133

134134
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.
135135

136-
### Create a viewer web app
136+
## Create a viewer web app
137137

138138
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.
139139

@@ -148,21 +148,21 @@ You see the site but no events have been posted to it yet.
148148

149149
![View new site](media/functions-bindings-event-grid/view-site.png)
150150

151-
### Create an Event Grid subscription
151+
## Create an Event Grid subscription
152152

153153
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`
154154

155155
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.
156156

157-
### Generate a request
157+
## Generate a request
158158

159159
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.
160160

161161
The subscription validation request will be received first; ignore any validation requests, and copy the event request.
162162

163163
![Copy request body from web app](media/functions-bindings-event-grid/view-results.png)
164164

165-
### Manually post the request
165+
## Manually post the request
166166

167167
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.
168168

@@ -173,13 +173,13 @@ Use your HTTP test tool to create an HTTP POST request:
173173
* Paste the RequestBin data into the request body.
174174
* Send an HTTP POST request to the endpoint that manually starts the Event Grid trigger.
175175

176-
#### [v2.x+](#tab/v2)
176+
### [v2.x+](#tab/v2)
177177

178178
```
179179
http://localhost:7071/runtime/webhooks/eventgrid?functionName={FUNCTION_NAME}
180180
```
181181
182-
#### [v1.x](#tab/v1)
182+
### [v1.x](#tab/v1)
183183
184184
```
185185
http://localhost:7071/admin/extensions/EventGridExtensionConfig?functionName={FUNCTION_NAME}
@@ -198,4 +198,4 @@ The Event Grid trigger function executes and shows logs similar to the following
198198
To learn more about Event Grid with Functions, see the following articles:
199199
200200
+ [Azure Event Grid bindings for Azure Functions](functions-bindings-event-grid.md)
201-
+ [Tutorial: Automate resizing uploaded images using Event Grid](../event-grid/resize-images-on-storage-blob-upload-event.md?toc=%2fazure%2fazure-functions%2ftoc.json)
201+
+ [Tutorial: Automate resizing uploaded images using Event Grid](../event-grid/resize-images-on-storage-blob-upload-event.md?toc=%2fazure%2fazure-functions%2ftoc.json)

0 commit comments

Comments
 (0)