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/cloud-event-schema.md
+133-9Lines changed: 133 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,18 @@
1
1
---
2
2
title: CloudEvents v1.0 schema with Azure Event Grid
3
3
description: Describes how to use the CloudEvents v1.0 schema for events in Azure Event Grid. The service supports events in the JSON implementation of Cloud Events.
4
-
ms.topic: conceptual
5
-
ms.date: 05/24/2023
4
+
ms.topic: how-to
5
+
ms.date: 09/24/2024
6
+
#customer intent: As a developer, I want to know how to use Cloud Events schema with Azure Event Grid.
6
7
---
7
8
8
9
# CloudEvents v1.0 schema with Azure Event Grid
9
10
10
-
Azure Event Grid natively supports events in the [JSON implementation of CloudEvents v1.0](https://github.com/cloudevents/spec/blob/v1.0/json-format.md) and [HTTP protocol binding](https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md). [CloudEvents](https://cloudevents.io/) is an [open specification](https://github.com/cloudevents/spec/blob/v1.0/spec.md) for describing event data.
11
-
12
-
CloudEvents simplifies interoperability by providing a common event schema for publishing, and consuming cloud based events. This schema allows for uniform tooling, standard ways of routing & handling events, and universal ways of deserializing the outer event schema. With a common schema, you can more easily integrate work across platforms.
11
+
Azure Event Grid natively supports events in the [JSON implementation of CloudEvents v1.0](https://github.com/cloudevents/spec/blob/v1.0/json-format.md) and [HTTP protocol binding](https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md). [CloudEvents](https://cloudevents.io/) is an [open specification](https://github.com/cloudevents/spec/blob/v1.0/spec.md) for describing event data. CloudEvents simplifies interoperability by providing a common event schema for publishing, and consuming cloud based events. This schema allows for uniform tooling, standard ways of routing & handling events, and universal ways of deserializing the outer event schema. With a common schema, you can more easily integrate work across platforms.
13
12
14
13
CloudEvents is being built by several [collaborators](https://github.com/cloudevents/spec/blob/main/docs/contributors.md), including Microsoft, through the [Cloud Native Computing Foundation](https://www.cncf.io/). It's currently available as version 1.0.
15
14
16
-
This article describes CloudEvents schema with Event Grid.
15
+
This article describes using CloudEvents schema with Event Grid.
17
16
18
17
## Sample event using CloudEvents schema
19
18
@@ -48,7 +47,7 @@ A detailed description of the available fields, their types, and definitions in
48
47
49
48
The headers values for events delivered in the CloudEvents schema and the Event Grid schema are the same except for `content-type`. For CloudEvents schema, that header value is `"content-type":"application/cloudevents+json; charset=utf-8"`. For Event Grid schema, that header value is `"content-type":"application/json; charset=utf-8"`.
50
49
51
-
## Event Grid for CloudEvents
50
+
## Configuration for CloudEvents
52
51
53
52
You can use Event Grid for both input and output of events in CloudEvents schema. You can use CloudEvents for system events, like Blob Storage events and IoT Hub events, and custom events. In addition to supporting CloudEvents, Event Grid supports a proprietary, nonextensible, yet fully functional [Event Grid event format](event-schema.md). The following table describes the transformation supported when using CloudEvents and Event Grid formats as an input schema in topics and as an output schema in event subscriptions. An Event Grid output schema can't be used when using CloudEvents as an input schema because CloudEvents supports [extension attributes](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/primer.md#cloudevent-attribute-extensions) that aren't supported by the Event Grid schema.
54
53
@@ -61,5 +60,130 @@ You can use Event Grid for both input and output of events in CloudEvents schema
61
60
62
61
For all event schemas, Event Grid requires validation when publishing to an Event Grid topic and when creating an event subscription. For more information, see [Event Grid security and authentication](security-authentication.md).
63
62
64
-
## Next steps
65
-
See [How to use CloudEvents v1.0 schema with Event Grid](cloudevents-schema.md).
63
+
### Input schema
64
+
65
+
You set the input schema for a custom topic when you create the custom topic by using the `input-schema` parameter.
If you're using Visual Studio or Visual Studio Code, and C# programming language to develop functions, make sure that you're using the latest [Microsoft.Azure.WebJobs.Extensions.EventGrid](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/) NuGet package (version **3.3.1** or above).
105
+
106
+
In Visual Studio, use the **Tools** -> **NuGet Package Manager** -> **Package Manager Console**, and run the `Install-Package` command (`Install-Package Microsoft.Azure.WebJobs.Extensions.EventGrid -Version 3.3.1`). Alternatively, right-click the project in the Solution Explorer window, and select **Manage NuGet Packages** menu to browse for the NuGet package, and install or update it to the latest version.
107
+
108
+
In VS Code, update the version number for the **Microsoft.Azure.WebJobs.Extensions.EventGrid** package in the **csproj** file for your Azure Functions project.
The following example shows an Azure Functions version 3.x function that's developed in either Visual Studio or Visual Studio Code. It uses a `CloudEvent` binding parameter and `EventGridTrigger`.
logger.LogInformation("Event received {type} {subject}", e.Type, e.Subject);
148
+
}
149
+
}
150
+
}
151
+
```
152
+
153
+
### Azure portal development experience
154
+
155
+
If you're using the Azure portal to develop an Azure function, follow these steps:
156
+
157
+
1. Update the name of the parameter in `function.json` file to `cloudEvent`.
158
+
159
+
```json
160
+
{
161
+
"bindings": [
162
+
{
163
+
"type": "eventGridTrigger",
164
+
"name": "cloudEvent",
165
+
"direction": "in"
166
+
}
167
+
]
168
+
}
169
+
```
170
+
1. Update the `run.csx` file as shown in the following sample code.
171
+
172
+
```csharp
173
+
#r "Azure.Core"
174
+
175
+
using Azure.Messaging;
176
+
177
+
public static void Run(CloudEvent cloudEvent, ILogger logger)
178
+
{
179
+
logger.LogInformation("Event received {type} {subject}", cloudEvent.Type, cloudEvent.Subject);
180
+
}
181
+
```
182
+
183
+
> [!NOTE]
184
+
> For more information, see [Azure Event Grid trigger for Azure Functions](../azure-functions/functions-bindings-event-grid-trigger.md?tabs=in-process%2Cextensionv3&pivots=programming-language-csharp).
Copy file name to clipboardExpand all lines: articles/event-grid/concepts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ The maximum allowed size for an event is 1 MB. Events over 64 KB are charged in
33
33
34
34
## Other formats
35
35
36
-
Event Grid also supports the proprietary [Event Grid schema](event-schema.md) format for [system events publishers](event-schema-api-management.md?tabs=cloud-event-schema). You can configure Event Grid to [deliver events using the CloudEvents](cloud-event-schema.md#event-grid-for-cloudevents) format.
36
+
Event Grid also supports the proprietary [Event Grid schema](event-schema.md) format for [system events publishers](event-schema-api-management.md?tabs=cloud-event-schema). You can configure Event Grid to [deliver events using the CloudEvents](cloud-event-schema.md#configuration-for-cloudevents) format.
0 commit comments