Skip to content

Commit 78cbc00

Browse files
authored
Merge pull request #218332 from spelluru/egridfunc1114
review & update
2 parents 38544d9 + 6ac2d50 commit 78cbc00

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
Binary file not shown.

articles/event-grid/receive-events.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Receive events from Azure Event Grid to an HTTP endpoint
33
description: Describes how to validate an HTTP endpoint, then receive and deserialize Events from Azure Event Grid
44
ms.topic: conceptual
5-
ms.date: 07/16/2021
5+
ms.date: 11/14/2022
66
ms.devlang: csharp, javascript
77
ms.custom: devx-track-js, devx-track-csharp
88
---
@@ -28,7 +28,7 @@ SDKs for other languages are available via the [Publish SDKs](./sdk-overview.md#
2828

2929
The first thing you want to do is handle `Microsoft.EventGrid.SubscriptionValidationEvent` events. Every time someone subscribes to an event, Event Grid sends a validation event to the endpoint with a `validationCode` in the data payload. The endpoint is required to echo this back in the response body to [prove the endpoint is valid and owned by you](webhook-event-delivery.md). If you're using an [Event Grid Trigger](../azure-functions/functions-bindings-event-grid.md) rather than a WebHook triggered Function, endpoint validation is handled for you. If you use a third-party API service (like [Zapier](https://zapier.com/home) or [IFTTT](https://ifttt.com/)), you might not be able to programmatically echo the validation code. For those services, you can manually validate the subscription by using a validation URL that is sent in the subscription validation event. Copy that URL in the `validationUrl` property and send a GET request either through a REST client or your web browser.
3030

31-
In C#, the `ParseMany()` method is used to deserialize a `BinaryData` instance containing 1 or more events into an array of `EventGridEvent`. If you knew ahead of time that your are deserializing only a single event, you could use the `Parse` method instead.
31+
In C#, the `ParseMany()` method is used to deserialize a `BinaryData` instance containing 1 or more events into an array of `EventGridEvent`. If you knew ahead of time that you are deserializing only a single event, you could use the `Parse` method instead.
3232

3333
To programmatically echo the validation code, use the following code.
3434

@@ -123,7 +123,7 @@ Test the validation response function by pasting the sample event into the test
123123
}]
124124
```
125125

126-
When you click Run, the Output should be 200 OK and `{"validationResponse":"512d38b6-c7b8-40c8-89fe-f46f9e9622b6"}` in the body:
126+
When you select Run, the Output should be 200 OK and `{"validationResponse":"512d38b6-c7b8-40c8-89fe-f46f9e9622b6"}` in the body:
127127

128128
:::image type="content" source="./media/receive-events/validation-request.png" alt-text="Validation request":::
129129

@@ -249,9 +249,15 @@ Test the new functionality of the function by putting a [Blob storage event](./e
249249

250250
You should see the blob URL output in the function log:
251251

252-
![Output log](./media/receive-events/blob-event-response.png)
252+
```
253+
2022-11-14T22:40:45.978 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=8429137d-9245-438c-8206-f9e85ef5dd61)
254+
2022-11-14T22:40:46.012 [Information] C# HTTP trigger function processed a request.
255+
2022-11-14T22:40:46.017 [Information] Received events: [{"topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount","subject": "/blobServices/default/containers/testcontainer/blobs/testfile.txt","eventType": "Microsoft.Storage.BlobCreated","eventTime": "2017-06-26T18:41:00.9584103Z","id": "831e1650-001e-001b-66ab-eeb76e069631","data": {"api": "PutBlockList","clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760","requestId": "831e1650-001e-001b-66ab-eeb76e000000","eTag": "0x8D4BCC2E4835CD0","contentType": "text/plain","contentLength": 524288,"blobType": "BlockBlob","url": "https://example.blob.core.windows.net/testcontainer/testfile.txt","sequencer": "00000000000004420000000000028963","storageDiagnostics": {"batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"}},"dataVersion": "","metadataVersion": "1"}]
256+
2022-11-14T22:40:46.335 [Information] Got BlobCreated event data, blob URI https://example.blob.core.windows.net/testcontainer/testfile.txt
257+
2022-11-14T22:40:46.346 [Information] Executed 'Function1' (Succeeded, Id=8429137d-9245-438c-8206-f9e85ef5dd61, Duration=387ms)
258+
```
253259

254-
You can also test by creating a Blob storage account or General Purpose V2 (GPv2) Storage account, [adding and event subscription](../storage/blobs/storage-blob-event-quickstart.md), and setting the endpoint to the function URL:
260+
You can also test by creating a Blob storage account or General Purpose V2 (GPv2) Storage account, [adding an event subscription](../storage/blobs/storage-blob-event-quickstart.md), and setting the endpoint to the function URL:
255261

256262
![Function URL](./media/receive-events/function-url.png)
257263

0 commit comments

Comments
 (0)