Skip to content

Commit f3e91be

Browse files
committed
Adding .NET Isolated to event based blob trigger tutorial
1 parent a79fd98 commit f3e91be

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

articles/azure-functions/functions-event-grid-blob-trigger.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ When you create a Blob Storage-triggered function using Visual Studio Code, you
8585
1. At the prompts, provide the following information:
8686

8787
::: zone pivot="programming-language-csharp"
88+
# [In-process](#tab/in-process)
8889
|Prompt|Action|
8990
|--|--|
9091
|**Select a language**| Select `C#`. |
91-
|**Select a .NET runtime**| Select `.NET 6.0 LTS`. Event-driven blob triggers aren't yet supported when running in an isolated worker process. |
92+
|**Select a .NET runtime**| Select `.NET 6.0 Isolated LTS` for running in an isolated worker process or `.NET 6.0 LTS` for in-process. |
9293
|**Select a template for your project's first function**| Select `Azure Blob Storage trigger`. |
9394
|**Provide a function name**| Enter `BlobTriggerEventGrid`. |
9495
|**Provide a namespace** | Enter `My.Functions`. |
@@ -156,27 +157,27 @@ To use the Event Grid-based Blob Storage trigger, your function requires at leas
156157
::: zone pivot="programming-language-csharp"
157158
To upgrade your project with the required extension version, in the Terminal window, run the following command: [dotnet add package](/dotnet/core/tools/dotnet-add-package)
158159

159-
<!---# [In-process](#tab/in-process) -->
160+
# [Isolated process](#tab/isolated-process)
160161
```bash
161-
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage --version 5.0.1
162+
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs --version 6.1.0
162163
```
163-
<!---# [Isolated process](#tab/isolated-process)
164+
# [In-process](#tab/in-process)
164165
```bash
165-
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Storage --version 5.0.0
166+
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage --version 5.1.3
166167
```
167168
---
168-
-->
169+
169170
::: zone-end
170171
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
171172

172173
1. Open the host.json project file, and inspect the `extensionBundle` element.
173174

174-
1. If `extensionBundle.version` isn't at least `3.3.0 `, replace `extensionBundle` with the following version:
175+
1. If `extensionBundle.version` isn't at least `3.3.0 `, replace `extensionBundle` with the latest:
175176

176177
```json
177178
"extensionBundle": {
178179
"id": "Microsoft.Azure.Functions.ExtensionBundle",
179-
"version": "[3.3.0, 4.0.0)"
180+
"version": "[4.0.0, 5.0.0)"
180181
}
181182
```
182183

@@ -186,14 +187,26 @@ dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Storage --version
186187

187188
::: zone pivot="programming-language-csharp"
188189
In the BlobTriggerEventGrid.cs file, add `Source = BlobTriggerSource.EventGrid` to the parameters for the Blob trigger attribute, for example:
189-
190+
191+
# [Isolated process](#tab/isolated-process)
192+
```csharp
193+
[Function("BlobTriggerCSharp")]
194+
public async Task Run([BlobTrigger("samples-workitems/{name}", Source = BlobTriggerSource.EventGrid, Connection = "<NAMED_STORAGE_CONNECTION>")] Stream myBlob, string name, FunctionContext executionContext)
195+
{
196+
var logger = executionContext.GetLogger("BlobTriggerCSharp");
197+
logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {name} \n Size: {myBlob.Length} Bytes");
198+
}
199+
```
200+
# [In-process](#tab/in-process)
190201
```csharp
191202
[FunctionName("BlobTriggerCSharp")]
192203
public static void Run([BlobTrigger("samples-workitems/{name}", Source = BlobTriggerSource.EventGrid, Connection = "<NAMED_STORAGE_CONNECTION>")]Stream myBlob, string name, ILogger log)
193204
{
194205
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
195206
}
196207
```
208+
---
209+
197210
::: zone-end
198211
::: zone pivot="programming-language-python"
199212
After you create the function, in the function.json configuration file, add `"source": "EventGrid"` to the `myBlob` binding, for example:
@@ -270,10 +283,17 @@ Event Grid validates the endpoint URL when you create an event subscription in t
270283

271284
When your function runs locally, the default endpoint used for an event-driven blob storage trigger looks like the following URL:
272285

273-
::: zone pivot="programming-language-csharp"
286+
::: zone pivot="programming-language-csharp"
287+
# [Isolated process](#tab/isolated-process)
288+
```http
289+
http://localhost:7071/runtime/webhooks/blobs?functionName=Host.Functions.BlobTriggerEventGrid
290+
```
291+
# [In-process](#tab/in-process)
274292
```http
275293
http://localhost:7071/runtime/webhooks/blobs?functionName=BlobTriggerEventGrid
276294
```
295+
---
296+
277297
::: zone-end
278298
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
279299
```http
@@ -317,12 +337,17 @@ The endpoint used in the event subscription is made up of three different parts,
317337
| --- | --- |
318338
| Prefix and server name | When your function runs locally, the server name with an `https://` prefix comes from the **Forwarding** URL generated by *ngrok*. In the localhost URL, the *ngrok* URL replaces `http://localhost:7071`. When running in Azure, you'll instead use the published function app server, which is usually in the form `https://<FUNCTION_APP_NAME>.azurewebsites.net`. |
319339
| Path | The path portion of the endpoint URL comes from the localhost URL copied earlier, and looks like `/runtime/webhooks/blobs` for a Blob Storage trigger. The path for an Event Grid trigger would be `/runtime/webhooks/EventGrid` |
320-
| Query string | The `functionName=BlobTriggerEventGrid` parameter in the query string sets the name of the function that handles the event. For functions other than C#, the function name is qualified by `Host.Functions.`. If you used a different name for your function, you'll need to change this value. An access key isn't required when running locally. When running in Azure, you'll also need to include a `code=` parameter in the URL, which contains a key that you can get from the portal. |
340+
| Query string | For all languages including .NET Isolated the `functionName=Host.Functions.BlobTriggerEventGrid` parameter, except for .NET In-process which should be `functionName=BlobTriggerEventGrid` in the query string sets the name of the function that handles the event. If you used a different name for your function, you'll need to change this value. An access key isn't required when running locally. When running in Azure, you'll also need to include a `code=` parameter in the URL, which contains a key that you can get from the portal. |
321341

322342
The following screenshot shows an example of how the final endpoint URL should look when using a Blob Storage trigger named `BlobTriggerEventGrid`:
323343

324344
::: zone pivot="programming-language-csharp"
345+
# [Isolated process](#tab/isolated-process)
346+
![Endpoint selection](./media/functions-event-grid-blob-trigger/functions-event-grid-local-dev-event-subscription-endpoint-selection-qualified.png)
347+
# [In-process](#tab/in-process)
325348
![Endpoint selection](./media/functions-event-grid-blob-trigger/functions-event-grid-local-dev-event-subscription-endpoint-selection.png)
349+
---
350+
326351
::: zone-end
327352
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
328353
![Endpoint selection](./media/functions-event-grid-blob-trigger/functions-event-grid-local-dev-event-subscription-endpoint-selection-qualified.png)
@@ -368,7 +393,7 @@ An event subscription, powered by Azure Event Grid, raises events based on chang
368393
| **Name** | *myBlobLocalNgrokEventSub* | Name that identifies the event subscription. You can use the name to quickly find the event subscription. |
369394
| **Event Schema** | **Event Grid Schema** | Use the default schema for events. |
370395
| **System Topic Name** | *samples-workitems-blobs* | Name for the topic, which represents the container. The topic is created with the first subscription, and you'll use it for future event subscriptions. |
371-
| **Filter to Event Types** | *Blob Created*<br/>*Blob Deleted*|
396+
| **Filter to Event Types** | *Blob Created*|
372397
| **Endpoint Type** | **Web Hook** | The blob storage trigger uses a web hook endpoint. You would use Azure Functions for an Event Grid trigger. |
373398
| **Endpoint** | Your ngrok-based URL endpoint | Use the ngrok-based URL endpoint that you determined earlier. |
374399

@@ -449,9 +474,16 @@ You'll include this value in the query string of new endpoint URL.
449474
Create a new endpoint URL for the Blob Storage trigger based on the following example:
450475

451476
::: zone pivot="programming-language-csharp"
477+
# [Isolated process](#tab/isolated-process)
478+
```http
479+
https://<FUNCTION_APP_NAME>.azurewebsites.net/runtime/webhooks/blobs?functionName=Host.Functions.BlobTriggerEventGrid&code=<BLOB_EXTENSION_KEY>
480+
```
481+
# [In-process](#tab/in-process)
452482
```http
453483
https://<FUNCTION_APP_NAME>.azurewebsites.net/runtime/webhooks/blobs?functionName=BlobTriggerEventGrid&code=<BLOB_EXTENSION_KEY>
454484
```
485+
---
486+
455487
::: zone-end
456488
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
457489
```http
@@ -479,7 +511,7 @@ This time, you'll include the filter on the event subscription so that only JPEG
479511
| ------------ | ---------------- | ----------- |
480512
| **Name** | *myBlobAzureEventSub* | Name that identifies the event subscription. You can use the name to quickly find the event subscription. |
481513
| **Event Schema** | **Event Grid Schema** | Use the default schema for events. |
482-
| **Filter to Event Types** | *Blob Created*<br/>*Blob Deleted*|
514+
| **Filter to Event Types** | *Blob Created*|
483515
| **Endpoint Type** | **Web Hook** | The blob storage trigger uses a web hook endpoint. You would use Azure Functions for an Event Grid trigger. |
484516
| **Endpoint** | Your new Azure-based URL endpoint | Use the URL endpoint that you built, which includes the key value. |
485517

17.3 KB
Loading

0 commit comments

Comments
 (0)