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
logger.LogInformation("Event received {type} {subject}", e.Type, e.Subject);
146
-
}
147
-
}
148
-
}
149
-
```
150
-
151
-
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).
152
-
153
-
### Microsoft.Azure.WebJobs.Extensions.EventGrid
129
+
### Visual Studio or Visual Studio Code
154
130
155
131
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.2.1** or above).
156
132
@@ -180,6 +156,62 @@ In VS Code, update the version number for the **Microsoft.Azure.WebJobs.Extensio
180
156
</Project>
181
157
```
182
158
159
+
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);
177
+
}
178
+
}
179
+
}
180
+
```
181
+
182
+
### Azure portal development experience
183
+
184
+
If you're using the Azure portal to develop an Azure function, follow these steps:
185
+
186
+
1. Update the name of the parameter in `function.json` file to `cloudEvent`.
187
+
188
+
```json
189
+
{
190
+
"bindings": [
191
+
{
192
+
"type": "eventGridTrigger",
193
+
"name": "cloudEvent",
194
+
"direction": "in"
195
+
}
196
+
]
197
+
}
198
+
```
199
+
1. Update the `run.csx` file as shown in the following sample code.
200
+
201
+
```csharp
202
+
#r "Azure.Core"
203
+
204
+
using Azure.Messaging;
205
+
206
+
public static void Run(CloudEvent cloudEvent, ILogger logger)
207
+
{
208
+
logger.LogInformation("Event received {type} {subject}", cloudEvent.Type, cloudEvent.Subject);
209
+
}
210
+
```
211
+
212
+
> [!NOTE]
213
+
> 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).
0 commit comments