diff --git a/samples/durable-functions/dotnet/DistributedTracing/DistributedTracing.csproj b/samples/durable-functions/dotnet/DistributedTracing/DistributedTracing.csproj
index 06b56e08..5619a719 100644
--- a/samples/durable-functions/dotnet/DistributedTracing/DistributedTracing.csproj
+++ b/samples/durable-functions/dotnet/DistributedTracing/DistributedTracing.csproj
@@ -1,15 +1,18 @@
- net8.0
+ net10.0
v4
Exe
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/samples/durable-functions/dotnet/DistributedTracing/Functions.cs b/samples/durable-functions/dotnet/DistributedTracing/Functions.cs
index 0cc2c51e..e5f22b4b 100644
--- a/samples/durable-functions/dotnet/DistributedTracing/Functions.cs
+++ b/samples/durable-functions/dotnet/DistributedTracing/Functions.cs
@@ -11,7 +11,7 @@ public static class Functions
{
[Function("StartOrchestration")]
public static async Task HttpStart(
- [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
diff --git a/samples/durable-functions/dotnet/DistributedTracing/Program.cs b/samples/durable-functions/dotnet/DistributedTracing/Program.cs
index c2df7fbe..f23260f1 100644
--- a/samples/durable-functions/dotnet/DistributedTracing/Program.cs
+++ b/samples/durable-functions/dotnet/DistributedTracing/Program.cs
@@ -1,13 +1,34 @@
-using Microsoft.Azure.Functions.Worker;
+using Azure.Monitor.OpenTelemetry.Exporter;
+using Microsoft.Azure.Functions.Worker.OpenTelemetry;
+using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+using OpenTelemetry;
+using OpenTelemetry.Trace;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
- .ConfigureServices(services =>
+ .ConfigureServices((context, services) =>
{
- services.AddApplicationInsightsTelemetryWorkerService();
- services.ConfigureFunctionsApplicationInsights();
+ var connectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
+ if (!string.IsNullOrWhiteSpace(connectionString))
+ {
+ services.AddAzureClientsCore();
+ services.AddOptions()
+ .Configure((options, factory) =>
+ {
+ options.ConnectionString = connectionString;
+ var credentialSettings = context.Configuration.GetSection("AzureMonitorExporter");
+ if (!string.IsNullOrWhiteSpace(context.Configuration["AzureMonitorExporter:credential"]))
+ {
+ options.Credential = factory.CreateTokenCredential(credentialSettings);
+ }
+ });
+ services.AddOpenTelemetry()
+ .UseFunctionsWorkerDefaults()
+ .WithTracing(tracing => tracing.AddSource("Microsoft.DurableTask"))
+ .UseAzureMonitorExporter();
+ }
})
.Build();
diff --git a/samples/durable-functions/dotnet/DistributedTracing/README.md b/samples/durable-functions/dotnet/DistributedTracing/README.md
index 0f1e1b13..210158b0 100644
--- a/samples/durable-functions/dotnet/DistributedTracing/README.md
+++ b/samples/durable-functions/dotnet/DistributedTracing/README.md
@@ -8,23 +8,26 @@ This sample demonstrates how to enable distributed tracing in Durable Functions
## Prerequisites
-1. [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) or later
+1. [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or later
2. [Docker](https://www.docker.com/products/docker-desktop/)
3. [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local) v4+
## Quick Run (Local with Jaeger)
1. Start the infrastructure:
+
```bash
docker compose up -d
```
2. Run the function app:
+
```bash
func start
```
3. Trigger an orchestration:
+
```bash
curl -X POST http://localhost:7071/api/StartOrchestration
```
@@ -33,8 +36,28 @@ This sample demonstrates how to enable distributed tracing in Durable Functions
- **Jaeger UI:** http://localhost:16686
- **DTS Dashboard:** http://localhost:8082
+The compose file starts Jaeger but does not configure the Functions host or worker to export telemetry to it. An OTLP exporter and endpoint configuration are also needed; starting Jaeger alone does not send it traces.
+
## Key Configuration
+### HTTP authentication
+
+`StartOrchestration` requires a function or host key in Azure. Core Tools skips key enforcement locally by default; use `func start --enableAuth` to exercise it locally.
+
+For a deployed app, retrieve a non-admin host key into a shell variable and send it in a header:
+
+```bash
+FUNCTION_KEY=$(az functionapp keys list \
+ --resource-group "$AZURE_RESOURCE_GROUP" \
+ --name "$AZURE_FUNCTION_NAME" --query functionKeys.default --output tsv)
+curl -X POST -H "x-functions-key: ${FUNCTION_KEY}" \
+ "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/StartOrchestration"
+```
+
+Do not use the master key or expose keys in source control, logs, or browser code. Keys do not provide per-user or per-instance authorization; managed identity for backend services is unchanged. The returned Durable management URLs contain a system key: keep those URLs secret and poll them as returned.
+
+### Durable tracing
+
Distributed tracing is enabled in `host.json`:
```json
@@ -54,6 +77,8 @@ Distributed tracing is enabled in `host.json`:
When deployed to Azure with Application Insights configured:
+The Functions host uses OpenTelemetry and the Durable Task distributed tracing configuration above. When `APPLICATIONINSIGHTS_CONNECTION_STRING` is set, the worker exports telemetry to Azure Monitor and captures the `Microsoft.DurableTask` activity source to connect the starter to the orchestration trace. For user-assigned managed identity authentication, set `AzureMonitorExporter__credential` to `managedidentity` and `AzureMonitorExporter__clientId` to the identity's client ID, and grant that identity the Monitoring Metrics Publisher role on Application Insights. If `AzureMonitorExporter__credential` is not set, the exporter uses connection-string authentication.
+
1. Navigate to your Application Insights resource
2. Go to **Transaction Search**
3. Filter for events with Durable Functions prefixes (`orchestration:`, `activity:`)
diff --git a/samples/durable-functions/dotnet/DistributedTracing/host.json b/samples/durable-functions/dotnet/DistributedTracing/host.json
index 2174cb2e..cd854593 100644
--- a/samples/durable-functions/dotnet/DistributedTracing/host.json
+++ b/samples/durable-functions/dotnet/DistributedTracing/host.json
@@ -1,12 +1,7 @@
{
"version": "2.0",
+ "telemetryMode": "OpenTelemetry",
"logging": {
- "applicationInsights": {
- "samplingSettings": {
- "isEnabled": true,
- "excludedTypes": "Request"
- }
- },
"logLevel": {
"DurableTask.Core": "Warning"
}
diff --git a/samples/durable-functions/dotnet/LargePayload/LargePayload.csproj b/samples/durable-functions/dotnet/LargePayload/LargePayload.csproj
index 8dce54dc..158f441b 100644
--- a/samples/durable-functions/dotnet/LargePayload/LargePayload.csproj
+++ b/samples/durable-functions/dotnet/LargePayload/LargePayload.csproj
@@ -1,6 +1,6 @@
- net8.0
+ net10.0
v4
Exe
enable
@@ -9,13 +9,15 @@
-
+
-
-
-
+
+
+
+
+
diff --git a/samples/durable-functions/dotnet/LargePayload/LargePayloadOrchestration.cs b/samples/durable-functions/dotnet/LargePayload/LargePayloadOrchestration.cs
index e2b7dc66..e86bd2e8 100644
--- a/samples/durable-functions/dotnet/LargePayload/LargePayloadOrchestration.cs
+++ b/samples/durable-functions/dotnet/LargePayload/LargePayloadOrchestration.cs
@@ -15,7 +15,7 @@ public static class LargePayloadOrchestration
[Function("StartLargePayload")]
public static async Task HttpStart(
- [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
@@ -41,8 +41,10 @@ public static async Task LargePayloadRoundTrip(
LargePayloadRequest request = context.GetInput()
?? throw new InvalidOperationException("The orchestration input payload was not provided.");
+ ValidatePayload(request.Payload, request.RequestedPayloadBytes);
string echoedPayload = await context.CallActivityAsync(nameof(EchoLargePayload), request.Payload)
?? throw new InvalidOperationException("The activity did not return a payload.");
+ ValidatePayload(echoedPayload, request.RequestedPayloadBytes);
int orchestrationInputBytes = GetUtf8ByteCount(request.Payload);
int activityOutputBytes = GetUtf8ByteCount(echoedPayload);
@@ -76,7 +78,7 @@ public static string EchoLargePayload(
[Function("Hello")]
public static async Task Hello(
- [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req)
+ [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req)
{
HttpResponseData response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteStringAsync("LargePayload sample is running. POST /api/StartLargePayload to start a >1 MB orchestration.");
@@ -99,6 +101,25 @@ private static string CreatePayload(int payloadSizeBytes)
});
}
+ private static void ValidatePayload(string payload, int expectedSizeBytes)
+ {
+ if (payload.Length != expectedSizeBytes)
+ {
+ throw new InvalidOperationException("The payload size did not match the requested size.");
+ }
+
+ const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ uint state = 0x00C0FFEEu;
+ for (int i = 0; i < payload.Length; i++)
+ {
+ state = (state * 1664525) + 1013904223;
+ if (payload[i] != Alphabet[(int)(state >> 26)])
+ {
+ throw new InvalidOperationException($"Invalid payload content at offset {i}.");
+ }
+ }
+ }
+
private static int GetPositiveIntSetting(string key, int defaultValue)
{
string? rawValue = Environment.GetEnvironmentVariable(key);
diff --git a/samples/durable-functions/dotnet/LargePayload/Program.cs b/samples/durable-functions/dotnet/LargePayload/Program.cs
index 4b07a32c..3d177e02 100644
--- a/samples/durable-functions/dotnet/LargePayload/Program.cs
+++ b/samples/durable-functions/dotnet/LargePayload/Program.cs
@@ -1,13 +1,31 @@
-using Microsoft.Azure.Functions.Worker;
+using Azure.Monitor.OpenTelemetry.Exporter;
+using Microsoft.Azure.Functions.Worker.OpenTelemetry;
+using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
- .ConfigureServices(services =>
+ .ConfigureServices((context, services) =>
{
- services.AddApplicationInsightsTelemetryWorkerService();
- services.ConfigureFunctionsApplicationInsights();
+ string? connectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
+ if (!string.IsNullOrWhiteSpace(connectionString))
+ {
+ services.AddAzureClientsCore();
+ services.AddOptions()
+ .Configure((options, factory) =>
+ {
+ options.ConnectionString = connectionString;
+ var credentialSettings = context.Configuration.GetSection("AzureMonitorExporter");
+ if (!string.IsNullOrWhiteSpace(context.Configuration["AzureMonitorExporter:credential"]))
+ {
+ options.Credential = factory.CreateTokenCredential(credentialSettings);
+ }
+ });
+ services.AddOpenTelemetry()
+ .UseFunctionsWorkerDefaults()
+ .UseAzureMonitorExporter();
+ }
})
.Build();
diff --git a/samples/durable-functions/dotnet/LargePayload/README.md b/samples/durable-functions/dotnet/LargePayload/README.md
index 78c52ece..145ce810 100644
--- a/samples/durable-functions/dotnet/LargePayload/README.md
+++ b/samples/durable-functions/dotnet/LargePayload/README.md
@@ -27,7 +27,9 @@ The flow is intentionally simple:
1. An HTTP trigger starts an orchestration with a payload larger than 1 MB.
2. The orchestrator sends that payload to a single activity.
3. The activity echoes the payload back.
-4. The orchestration returns a small summary proving the payload survived the round-trip.
+4. The orchestrator checks both its input and the activity output character by character against the expected deterministic content, without allocating another full payload, then returns a small summary.
+
+An equal byte count is not enough: same-length corruption, an unresolved blob reference, or a truncated payload fails the orchestration. `PayloadsMatch` also compares the full input and output, not just their lengths.
This is exactly why large payload support exists: without blob offload, a payload this size would be too large to flow through DTS messages directly.
@@ -42,7 +44,7 @@ The sample enables these settings in `host.json`:
"connectionStringName": "DTS_CONNECTION_STRING",
"payloadStorageEnabled": true,
"payloadStorageThresholdBytes": 262144,
- "payloadStorageMaxPayloadBytes": 15728640
+ "payloadStorageMaxSizeBytes": 15728640
},
"hubName": "%TASKHUB_NAME%"
}
@@ -59,31 +61,31 @@ The sample uses a deterministic, low-compressibility **1.5 MiB** payload by defa
### Maximum payload size
-`payloadStorageThresholdBytes` controls *when* a payload is externalized. A separate setting, `payloadStorageMaxPayloadBytes`, controls the **largest single serialized UTF-8 payload** the runtime will externalize:
+`payloadStorageThresholdBytes` controls *when* a payload is externalized. A separate setting, `payloadStorageMaxSizeBytes`, controls the **largest single serialized UTF-8 payload** the runtime will externalize:
-- If you don't set `payloadStorageMaxPayloadBytes`, the default maximum is **10 MB (10,485,760 bytes, shown as 10,240 KB in the error message)**.
+- If you don't set `payloadStorageMaxSizeBytes`, the default maximum is **10 MB (10,485,760 bytes, shown as 10,240 KB in the error message)**.
- A request whose payload exceeds the maximum **fails fast** — before the orchestration is scheduled — with an error like:
```text
Payload size 10742 KB exceeds the configured maximum of 10240 KB. Reduce the payload size or increase the max payload size limit.
```
-- This is a **configurable limit, not a hard product limit**. To allow larger payloads, raise `payloadStorageMaxPayloadBytes` in `host.json`. This sample sets it to `15728640` (15 MiB), including JSON serialization overhead.
+- This is a **configurable limit, not a hard product limit**. To allow larger payloads, raise `payloadStorageMaxSizeBytes` in `host.json`. This sample sets it to `15728640` (15 MiB), including JSON serialization overhead.
-#### `PAYLOAD_SIZE_BYTES` is not `payloadStorageMaxPayloadBytes`
+#### `PAYLOAD_SIZE_BYTES` is not `payloadStorageMaxSizeBytes`
These two settings are easy to confuse but do completely different things:
| Setting | Where it lives | What it controls |
|---|---|---|
| `PAYLOAD_SIZE_BYTES` | app setting / `local.settings.json` | How many bytes of test data **this sample generates** for its demo payload. |
-| `payloadStorageMaxPayloadBytes` | `host.json` | The **maximum** size the runtime will externalize. Payloads larger than this fail fast. |
+| `payloadStorageMaxSizeBytes` | `host.json` | The **maximum** size the runtime will externalize. Payloads larger than this fail fast. |
-If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxPayloadBytes` (for example `PAYLOAD_SIZE_BYTES=11000000` against the default 10 MB cap), the run fails **by design** with the error above. Set the cap above the generated data size, leaving room for the JSON string quotes and request fields. Setting the two values equal can still exceed the cap after serialization.
+If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxSizeBytes` (for example `PAYLOAD_SIZE_BYTES=11000000` against the default 10 MB cap), the run fails **by design** with the error above. Set the cap above the generated data size, leaving room for the JSON string quotes and request fields. Setting the two values equal can still exceed the cap after serialization.
## Prerequisites
-- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
+- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
- [Azure Functions Core Tools v4](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
- [Docker](https://www.docker.com/products/docker-desktop/)
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli)
@@ -150,6 +152,12 @@ If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxPayloadBytes` (for exa
The extension stores payload blobs with gzip content encoding, so Azure shows the compressed on-disk size. Because this sample uses low-compressibility payload content, the stored blob sizes should stay reasonably close to the logical 1.5 MiB payload instead of collapsing to a tiny repetitive-text blob.
+### Blob retention policy
+
+This sample configures no time-based Blob Storage lifecycle rule or scheduled cleanup. Do not treat orchestration completion as a guarantee that payload blobs have been deleted. Keep `durabletask-payloads` available while any referencing instance can run, retry, replay, or be inspected with inputs/outputs.
+
+For a retained environment, define an operational retention period covering the longest orchestration lifetime, recovery window, and history-access requirements. After all referencing instances are terminal and that period has elapsed, purge their durable histories and verify payload cleanup for the deployed extension version; remove remaining unreferenced blobs with an instance-aware cleanup process. Do not apply a blanket age-based deletion rule to live payloads: deleting a still-referenced blob breaks replay and status retrieval. Soft-deleted blobs and versions may remain billable under the storage account's retention settings. For this disposable sample, deleting the dedicated environment under **Clean up** also removes its storage.
+
## Local settings
| Setting | Description | Default |
@@ -157,7 +165,7 @@ The extension stores payload blobs with gzip content encoding, so Azure shows th
| `DTS_CONNECTION_STRING` | DTS emulator or Azure connection string | `Endpoint=http://localhost:8080;Authentication=None` |
| `TASKHUB_NAME` | Task hub name | `default` |
| `AzureWebJobsStorage` | Storage for Functions host state and payload blobs | `UseDevelopmentStorage=true` locally |
-| `PAYLOAD_SIZE_BYTES` | Size of the test payload this sample generates. Keep it below `payloadStorageMaxPayloadBytes` (15 MiB in this sample), leaving room for JSON serialization overhead. | `1572864` |
+| `PAYLOAD_SIZE_BYTES` | Size of the test payload this sample generates. Keep it below `payloadStorageMaxSizeBytes` (15 MiB in this sample), leaving room for JSON serialization overhead. | `1572864` |
## Deploy to Azure with AZD
@@ -179,9 +187,10 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
The deployment provisions:
- an Azure Function App
- - a storage account used for `AzureWebJobsStorage`
+ - a storage account used for `AzureWebJobsStorage`, with a blob private endpoint
- a Durable Task Scheduler resource and task hub
- - a user-assigned managed identity with the required DTS and storage permissions
+ - Application Insights and Log Analytics
+ - a user-assigned managed identity with the required DTS, storage, and monitoring permissions
3. Load the environment values:
@@ -192,10 +201,14 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
4. Start the orchestration in Azure:
```bash
- curl -X POST "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/StartLargePayload"
+ FUNCTION_KEY=$(az functionapp keys list \
+ --resource-group "$AZURE_RESOURCE_GROUP" \
+ --name "$AZURE_FUNCTION_NAME" --query functionKeys.default --output tsv)
+ curl -X POST -H "x-functions-key: ${FUNCTION_KEY}" \
+ "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/StartLargePayload"
```
-5. Verify payload blobs in Azure storage:
+5. Verify payload blobs in Azure storage. The storage firewall denies public access by default; the deployment script allows the deploying machine's IP so this command can run from there:
```bash
az storage blob list \
@@ -207,6 +220,20 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
6. Open the DTS dashboard URL in the Azure portal to inspect the orchestration history.
+## HTTP authentication
+
+All HTTP triggers, including `Hello`, require a function or host key in Azure. The example uses a non-admin host key; never use the master key for application requests. Keep keys out of source control, logs, shared command output, and browser bundles; rotate them if exposed. Keys grant access, not per-user or per-instance authorization. Managed identity for DTS and Storage is unchanged.
+
+Core Tools normally skips HTTP key enforcement locally, so the local examples need no key. Use `func start --enableAuth` to exercise key enforcement. The returned Durable management URLs carry a system key in their query string: treat the entire URLs as secrets and poll them as returned, without replacing their key with the starter key.
+
+## Telemetry
+
+The Functions host uses OpenTelemetry (`telemetryMode` in `host.json`).
+
+When `APPLICATIONINSIGHTS_CONNECTION_STRING` is set, the worker registers OpenTelemetry and exports to Azure Monitor. The exporter authenticates with the app's managed identity through the dedicated `AzureMonitorExporter` settings (`AzureMonitorExporter__credential` and `AzureMonitorExporter__clientId`), so Application Insights local authentication can stay disabled. Unless `AzureMonitorExporter__credential` is explicitly set, the exporter uses connection-string authentication. Without that connection string, as in local emulator runs, the worker does not export.
+
+In Application Insights, inspect `requests`, `dependencies`, and `traces` for exported telemetry. Payload contents are not logged.
+
## Files to look at
- `LargePayloadOrchestration.cs` — HTTP starter, orchestrator, and echo activity
diff --git a/samples/durable-functions/dotnet/LargePayload/host.json b/samples/durable-functions/dotnet/LargePayload/host.json
index 480e57f6..b66ffd37 100644
--- a/samples/durable-functions/dotnet/LargePayload/host.json
+++ b/samples/durable-functions/dotnet/LargePayload/host.json
@@ -1,18 +1,10 @@
{
"version": "2.0",
+ "telemetryMode": "OpenTelemetry",
"logging": {
- "applicationInsights": {
- "samplingSettings": {
- "isEnabled": true,
- "excludedTypes": "Request"
- },
- "enableLiveMetricsFilters": true,
- "logLevel": {
- "Host.Triggers.DurableTask": "Information"
- }
- },
"logLevel": {
- "Function": "Information"
+ "Function": "Information",
+ "Host.Triggers.DurableTask": "Information"
}
},
"extensions": {
@@ -22,7 +14,7 @@
"connectionStringName": "DTS_CONNECTION_STRING",
"payloadStorageEnabled": true,
"payloadStorageThresholdBytes": 262144,
- "payloadStorageMaxPayloadBytes": 15728640
+ "payloadStorageMaxSizeBytes": 15728640
},
"hubName": "%TASKHUB_NAME%"
}
diff --git a/samples/durable-functions/dotnet/LargePayload/infra/app/durable-function.bicep b/samples/durable-functions/dotnet/LargePayload/infra/app/durable-function.bicep
index 0611a63b..751ff10d 100644
--- a/samples/durable-functions/dotnet/LargePayload/infra/app/durable-function.bicep
+++ b/samples/durable-functions/dotnet/LargePayload/infra/app/durable-function.bicep
@@ -31,9 +31,10 @@ module durableFunction '../core/host/functions.bicep' = {
AzureWebJobsStorage__clientId : identityClientId
AzureWebJobsStorage__credential : 'managedidentity'
APPLICATIONINSIGHTS_AUTHENTICATION_STRING: applicationInsightsIdentity
+ AzureMonitorExporter__credential: 'managedidentity'
+ AzureMonitorExporter__clientId: identityClientId
DTS_CONNECTION_STRING: 'Endpoint=${dtsURL};Authentication=ManagedIdentity;ClientID=${identityClientId}'
TASKHUB_NAME: taskHubName
- AZURE_CLIENT_ID: identityClientId
})
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
diff --git a/samples/durable-functions/dotnet/LargePayload/infra/main.bicep b/samples/durable-functions/dotnet/LargePayload/infra/main.bicep
index 26cad820..27dddc9e 100644
--- a/samples/durable-functions/dotnet/LargePayload/infra/main.bicep
+++ b/samples/durable-functions/dotnet/LargePayload/infra/main.bicep
@@ -118,7 +118,7 @@ module durableFunction './app/durable-function.bicep' = {
applicationInsightsName: monitoring.outputs.applicationInsightsName
appServicePlanId: appServicePlan.outputs.id
runtimeName: 'dotnet-isolated'
- runtimeVersion: '8.0'
+ runtimeVersion: '10.0'
storageAccountName: storage.outputs.name
deploymentStorageContainerName: deploymentStorageContainerName
identityId: durableFunctionUserAssignedIdentity.outputs.identityId
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadFanOutFanIn.csproj b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadFanOutFanIn.csproj
index 8dce54dc..158f441b 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadFanOutFanIn.csproj
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadFanOutFanIn.csproj
@@ -1,6 +1,6 @@
- net8.0
+ net10.0
v4
Exe
enable
@@ -9,13 +9,15 @@
-
+
-
-
-
+
+
+
+
+
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadOrchestration.cs b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadOrchestration.cs
index 36c3e447..e61ad135 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadOrchestration.cs
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/LargePayloadOrchestration.cs
@@ -16,7 +16,7 @@ public static class LargePayloadOrchestration
[Function("StartLargePayload")]
public static async Task HttpStart(
- [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
@@ -43,29 +43,39 @@ public static async Task LargePayloadFanOutFanIn(
LargePayloadFanOutRequest request = context.GetInput()
?? throw new InvalidOperationException("The orchestration input payload was not provided.");
- List> tasks = new(request.ActivityCount);
+ List> tasks = new(request.ActivityCount);
for (int i = 0; i < request.ActivityCount; i++)
{
- tasks.Add(context.CallActivityAsync(
- nameof(GenerateLargePayload),
+ tasks.Add(context.CallSubOrchestratorAsync(
+ nameof(GenerateAndValidatePayload),
new LargePayloadActivityRequest(i + 1, request.RequestedPayloadBytes)));
}
- string[] payloads = await Task.WhenAll(tasks);
- if (payloads.Any(payload => payload.StartsWith("blob:v1:", StringComparison.Ordinal)))
- {
- throw new InvalidOperationException("The orchestrator received a payload token instead of the resolved payload.");
- }
-
- int[] individualPayloadBytes = payloads.Select(GetUtf8ByteCount).ToArray();
+ LargePayloadActivitySummary[] summaries = await Task.WhenAll(tasks);
+ int[] individualPayloadBytes = summaries.Select(summary => summary.PayloadBytes).ToArray();
return new LargePayloadFanOutSummary(
- ActivityCount: payloads.Length,
+ ActivityCount: summaries.Length,
RequestedPayloadBytesPerActivity: request.RequestedPayloadBytes,
IndividualPayloadBytes: individualPayloadBytes,
- TotalPayloadBytes: individualPayloadBytes.Sum(),
+ TotalPayloadBytes: individualPayloadBytes.Sum(bytes => (long)bytes),
AllPayloadsExceededOneMiB: individualPayloadBytes.All(bytes => bytes > OneMiB),
- AllPayloadsMatchRequestedSize: individualPayloadBytes.All(bytes => bytes == request.RequestedPayloadBytes));
+ AllPayloadsMatchRequestedSize: individualPayloadBytes.All(bytes => bytes == request.RequestedPayloadBytes),
+ AllPayloadsMatchExpectedContent: summaries.All(summary => summary.ContentMatches));
+ }
+
+ [Function(nameof(GenerateAndValidatePayload))]
+ public static async Task GenerateAndValidatePayload(
+ [OrchestrationTrigger] TaskOrchestrationContext context)
+ {
+ LargePayloadActivityRequest request = context.GetInput()
+ ?? throw new InvalidOperationException("The activity request was not provided.");
+
+ // Keep large results in separate histories; the parent only receives small summaries.
+ string payload = await context.CallActivityAsync(nameof(GenerateLargePayload), request)
+ ?? throw new InvalidOperationException("The activity did not return a payload.");
+ ValidatePayload(payload, request.ActivityNumber, request.RequestedPayloadBytes);
+ return new LargePayloadActivitySummary(GetUtf8ByteCount(payload), ContentMatches: true);
}
[Function(nameof(GenerateLargePayload))]
@@ -87,7 +97,7 @@ public static string GenerateLargePayload(
[Function("Hello")]
public static async Task Hello(
- [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req)
+ [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req)
{
HttpResponseData response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteStringAsync("LargePayloadFanOutFanIn sample is running. POST /api/StartLargePayload to start parallel >1 MB activities.");
@@ -110,6 +120,25 @@ private static string CreatePayload(int activityNumber, int payloadSizeBytes)
});
}
+ private static void ValidatePayload(string payload, int activityNumber, int expectedSizeBytes)
+ {
+ if (payload.Length != expectedSizeBytes)
+ {
+ throw new InvalidOperationException($"Activity {activityNumber} returned an unexpected payload size.");
+ }
+
+ const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ uint state = 0x00C0FFEEu + (uint)activityNumber;
+ for (int i = 0; i < payload.Length; i++)
+ {
+ state = (state * 1664525) + 1013904223;
+ if (payload[i] != Alphabet[(int)(state >> 26)])
+ {
+ throw new InvalidOperationException($"Activity {activityNumber} returned invalid payload content at offset {i}.");
+ }
+ }
+ }
+
private static int GetPositiveIntSetting(string key, int defaultValue)
{
string? rawValue = Environment.GetEnvironmentVariable(key);
@@ -133,10 +162,13 @@ public sealed record LargePayloadFanOutRequest(int ActivityCount, int RequestedP
public sealed record LargePayloadActivityRequest(int ActivityNumber, int RequestedPayloadBytes);
+public sealed record LargePayloadActivitySummary(int PayloadBytes, bool ContentMatches);
+
public sealed record LargePayloadFanOutSummary(
int ActivityCount,
int RequestedPayloadBytesPerActivity,
int[] IndividualPayloadBytes,
- int TotalPayloadBytes,
+ long TotalPayloadBytes,
bool AllPayloadsExceededOneMiB,
- bool AllPayloadsMatchRequestedSize);
+ bool AllPayloadsMatchRequestedSize,
+ bool AllPayloadsMatchExpectedContent);
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/Program.cs b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/Program.cs
index 4b07a32c..3d177e02 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/Program.cs
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/Program.cs
@@ -1,13 +1,31 @@
-using Microsoft.Azure.Functions.Worker;
+using Azure.Monitor.OpenTelemetry.Exporter;
+using Microsoft.Azure.Functions.Worker.OpenTelemetry;
+using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
- .ConfigureServices(services =>
+ .ConfigureServices((context, services) =>
{
- services.AddApplicationInsightsTelemetryWorkerService();
- services.ConfigureFunctionsApplicationInsights();
+ string? connectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
+ if (!string.IsNullOrWhiteSpace(connectionString))
+ {
+ services.AddAzureClientsCore();
+ services.AddOptions()
+ .Configure((options, factory) =>
+ {
+ options.ConnectionString = connectionString;
+ var credentialSettings = context.Configuration.GetSection("AzureMonitorExporter");
+ if (!string.IsNullOrWhiteSpace(context.Configuration["AzureMonitorExporter:credential"]))
+ {
+ options.Credential = factory.CreateTokenCredential(credentialSettings);
+ }
+ });
+ services.AddOpenTelemetry()
+ .UseFunctionsWorkerDefaults()
+ .UseAzureMonitorExporter();
+ }
})
.Build();
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/README.md b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/README.md
index 3e5e407e..48494b89 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/README.md
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/README.md
@@ -24,10 +24,17 @@ If you want the smallest possible example, start with the sibling [LargePayload]
The flow is intentionally parallel:
-1. An HTTP trigger starts an orchestration with a payload size larger than 1 MB.
-2. The orchestrator fans out to multiple activities.
-3. Each activity generates a payload larger than 1 MB and returns it to the orchestrator.
-4. The orchestrator fans in and returns a small summary proving every activity payload survived the round-trip.
+1. An HTTP trigger starts an orchestration with a small request specifying the activity count and payload size.
+2. The orchestrator fans out to child orchestrations, each of which calls one activity.
+3. Each activity generates a payload larger than 1 MB and returns it to its child orchestrator.
+4. Each child validates every character against the deterministic sequence for its activity number, without allocating a second expected payload, and returns only a small summary.
+5. The parent fans in the summaries, never collecting the large activity results in its own history or a `string[]`.
+
+This reduces the parent's retained data to O(activity count) small summaries rather than O(activity count x payload size). It is not streaming blob deserialization: each child still materializes one payload, and concurrent children can consume memory on the same worker. Size worker concurrency and activity counts accordingly.
+
+The tradeoff is one extra child orchestration and its scheduling/history overhead per activity. `TotalPayloadBytes` is a 64-bit total so aggregating more than 2 GiB does not overflow.
+
+The orchestration history shape has changed from direct activity calls to child orchestrations. Before deploying over an older version, drain existing instances or deploy with a new task hub; do not replay in-flight instances against the changed orchestration.
This is exactly why large payload support exists: without blob offload, payloads this size would be too large to flow through DTS messages directly.
@@ -42,7 +49,7 @@ The sample enables these settings in `host.json`:
"connectionStringName": "DTS_CONNECTION_STRING",
"payloadStorageEnabled": true,
"payloadStorageThresholdBytes": 262144,
- "payloadStorageMaxPayloadBytes": 15728640
+ "payloadStorageMaxSizeBytes": 15728640
},
"hubName": "%TASKHUB_NAME%"
}
@@ -59,9 +66,9 @@ The sample uses **three deterministic, low-compressibility 1.5 MiB activity payl
### Maximum payload size
-`payloadStorageThresholdBytes` controls *when* a payload is externalized. A separate setting, `payloadStorageMaxPayloadBytes`, controls the **largest single serialized UTF-8 payload** the runtime will externalize:
+`payloadStorageThresholdBytes` controls *when* a payload is externalized. A separate setting, `payloadStorageMaxSizeBytes`, controls the **largest single serialized UTF-8 payload** the runtime will externalize:
-- If you don't set `payloadStorageMaxPayloadBytes`, the default maximum is **10 MB (10,485,760 bytes, shown as 10,240 KB in the error message)**.
+- If you don't set `payloadStorageMaxSizeBytes`, the default maximum is **10 MB (10,485,760 bytes, shown as 10,240 KB in the error message)**.
- The cap applies to each **single** externalized payload (here, each activity's payload), not the combined total across all activities.
- An activity output whose serialized payload exceeds the maximum fails when the runtime tries to externalize that result. The orchestration has already been scheduled: its input contains only the activity count and requested size, and each activity generates its payload later. The error is:
@@ -69,22 +76,22 @@ The sample uses **three deterministic, low-compressibility 1.5 MiB activity payl
Payload size 10742 KB exceeds the configured maximum of 10240 KB. Reduce the payload size or increase the max payload size limit.
```
-- This is a **configurable limit, not a hard product limit**. To allow larger payloads, raise `payloadStorageMaxPayloadBytes` in `host.json`. This sample sets it to `15728640` (15 MiB) per serialized payload, including JSON serialization overhead.
+- This is a **configurable limit, not a hard product limit**. To allow larger payloads, raise `payloadStorageMaxSizeBytes` in `host.json`. This sample sets it to `15728640` (15 MiB) per serialized payload, including JSON serialization overhead.
-#### `PAYLOAD_SIZE_BYTES` is not `payloadStorageMaxPayloadBytes`
+#### `PAYLOAD_SIZE_BYTES` is not `payloadStorageMaxSizeBytes`
These two settings are easy to confuse but do completely different things:
| Setting | Where it lives | What it controls |
-|---|---|---|
+| --- | --- | --- |
| `PAYLOAD_SIZE_BYTES` | app setting / `local.settings.json` | How many bytes of test data **each activity generates** for its demo payload. |
-| `payloadStorageMaxPayloadBytes` | `host.json` | The **maximum** size of any single payload the runtime will externalize. Larger payloads fail fast. |
+| `payloadStorageMaxSizeBytes` | `host.json` | The **maximum** size of any single payload the runtime will externalize. Larger payloads fail fast. |
-If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxPayloadBytes` (for example `PAYLOAD_SIZE_BYTES=11000000` against the default 10 MB cap), the run fails **by design** with the error above. Set the cap above the per-activity generated data size, leaving room for JSON string quotes. Setting the two values equal can still exceed the cap after serialization.
+If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxSizeBytes` (for example `PAYLOAD_SIZE_BYTES=11000000` against the default 10 MB cap), the run fails **by design** with the error above. Set the cap above the per-activity generated data size, leaving room for JSON string quotes. Setting the two values equal can still exceed the cap after serialization.
## Prerequisites
-- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
+- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
- [Azure Functions Core Tools v4](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
- [Docker](https://www.docker.com/products/docker-desktop/)
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli)
@@ -137,7 +144,8 @@ If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxPayloadBytes` (for exa
"IndividualPayloadBytes": [1572864, 1572864, 1572864],
"TotalPayloadBytes": 4718592,
"AllPayloadsExceededOneMiB": true,
- "AllPayloadsMatchRequestedSize": true
+ "AllPayloadsMatchRequestedSize": true,
+ "AllPayloadsMatchExpectedContent": true
}
}
```
@@ -153,14 +161,22 @@ If you raise `PAYLOAD_SIZE_BYTES` above `payloadStorageMaxPayloadBytes` (for exa
The extension stores payload blobs with gzip content encoding, so Azure shows the compressed on-disk size. Because this sample uses low-compressibility payload content, the stored blob sizes should stay reasonably close to the logical 1.5 MiB activity payloads instead of collapsing to tiny repetitive-text blobs.
+Length alone is not the integrity check: a same-length substitution, reordered payload from another activity, truncation, or unresolved blob token fails validation and fails the orchestration rather than returning a successful summary.
+
+### Blob retention policy
+
+This sample configures no time-based Blob Storage lifecycle rule or scheduled cleanup. Do not treat orchestration completion as a guarantee that payload blobs have been deleted. Keep `durabletask-payloads` available while any referencing parent or child instance can run, retry, replay, or be inspected with inputs/outputs.
+
+For a retained environment, define an operational retention period covering the longest orchestration lifetime, recovery window, and history-access requirements. After all referencing instances are terminal and that period has elapsed, purge their durable histories and verify payload cleanup for the deployed extension version; remove remaining unreferenced blobs with an instance-aware cleanup process. Do not apply a blanket age-based deletion rule to live payloads: deleting a still-referenced blob breaks replay and status retrieval. Soft-deleted blobs and versions may remain billable under the storage account's retention settings. For this disposable sample, deleting the dedicated environment under **Clean up** also removes its storage.
+
## Local settings
| Setting | Description | Default |
-|---|---|---|
+| --- | --- | --- |
| `DTS_CONNECTION_STRING` | DTS emulator or Azure connection string | `Endpoint=http://localhost:8080;Authentication=None` |
| `TASKHUB_NAME` | Task hub name | `default` |
| `AzureWebJobsStorage` | Storage for Functions host state and payload blobs | `UseDevelopmentStorage=true` locally |
-| `PAYLOAD_SIZE_BYTES` | Size of the test payload each activity generates. Keep it below `payloadStorageMaxPayloadBytes` (15 MiB in this sample), leaving room for JSON serialization overhead. | `1572864` |
+| `PAYLOAD_SIZE_BYTES` | Size of the test payload each activity generates. Keep it below `payloadStorageMaxSizeBytes` (15 MiB in this sample), leaving room for JSON serialization overhead. | `1572864` |
| `ACTIVITY_COUNT` | Number of parallel activity invocations | `3` |
## Deploy to Azure with AZD
@@ -183,9 +199,10 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
The deployment provisions:
- an Azure Function App
- - a storage account used for `AzureWebJobsStorage`
+ - a storage account used for `AzureWebJobsStorage`, with a blob private endpoint
- a Durable Task Scheduler resource and task hub
- - a user-assigned managed identity with the required DTS and storage permissions
+ - Application Insights and Log Analytics
+ - a user-assigned managed identity with the required DTS, storage, and monitoring permissions
3. Load the environment values:
@@ -196,10 +213,14 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
4. Start the orchestration in Azure:
```bash
- curl -X POST "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/StartLargePayload"
+ FUNCTION_KEY=$(az functionapp keys list \
+ --resource-group "$AZURE_RESOURCE_GROUP" \
+ --name "$AZURE_FUNCTION_NAME" --query functionKeys.default --output tsv)
+ curl -X POST -H "x-functions-key: ${FUNCTION_KEY}" \
+ "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/StartLargePayload"
```
-5. Verify payload blobs in Azure storage:
+5. Verify payload blobs in Azure storage. The storage firewall denies public access by default; the deployment script allows the deploying machine's IP so this command can run from there:
```bash
az storage blob list \
@@ -211,6 +232,20 @@ This sample includes `azure.yaml`, `infra/`, and deployment scripts so you can p
6. Open the DTS dashboard URL in the Azure portal to inspect the orchestration history.
+## HTTP authentication
+
+All HTTP triggers, including `Hello`, require a function or host key in Azure. The example uses a non-admin host key; never use the master key for application requests. Keep keys out of source control, logs, shared command output, and browser bundles; rotate them if exposed. Keys grant access, not per-user or per-instance authorization. Managed identity for DTS and Storage is unchanged.
+
+Core Tools normally skips HTTP key enforcement locally, so the local examples need no key. Use `func start --enableAuth` to exercise key enforcement. The returned Durable management URLs carry a system key in their query string: treat the entire URLs as secrets and poll them as returned, without replacing their key with the starter key.
+
+## Telemetry
+
+The Functions host uses OpenTelemetry (`telemetryMode` in `host.json`).
+
+When `APPLICATIONINSIGHTS_CONNECTION_STRING` is set, the worker registers OpenTelemetry and exports to Azure Monitor. The exporter authenticates with the app's managed identity through the dedicated `AzureMonitorExporter` settings (`AzureMonitorExporter__credential` and `AzureMonitorExporter__clientId`), so Application Insights local authentication can stay disabled. Unless `AzureMonitorExporter__credential` is explicitly set, the exporter uses connection-string authentication. Without that connection string, as in local emulator runs, the worker does not export.
+
+In Application Insights, inspect `requests`, `dependencies`, and `traces` for exported telemetry. Payload contents are not logged.
+
## Files to look at
- `LargePayloadOrchestration.cs` — HTTP starter, fan-out/fan-in orchestrator, and payload-generating activity
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/host.json b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/host.json
index 480e57f6..b66ffd37 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/host.json
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/host.json
@@ -1,18 +1,10 @@
{
"version": "2.0",
+ "telemetryMode": "OpenTelemetry",
"logging": {
- "applicationInsights": {
- "samplingSettings": {
- "isEnabled": true,
- "excludedTypes": "Request"
- },
- "enableLiveMetricsFilters": true,
- "logLevel": {
- "Host.Triggers.DurableTask": "Information"
- }
- },
"logLevel": {
- "Function": "Information"
+ "Function": "Information",
+ "Host.Triggers.DurableTask": "Information"
}
},
"extensions": {
@@ -22,7 +14,7 @@
"connectionStringName": "DTS_CONNECTION_STRING",
"payloadStorageEnabled": true,
"payloadStorageThresholdBytes": 262144,
- "payloadStorageMaxPayloadBytes": 15728640
+ "payloadStorageMaxSizeBytes": 15728640
},
"hubName": "%TASKHUB_NAME%"
}
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/app/durable-function.bicep b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/app/durable-function.bicep
index 1de57197..13fd1345 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/app/durable-function.bicep
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/app/durable-function.bicep
@@ -31,9 +31,10 @@ module durableFunction '../core/host/functions.bicep' = {
AzureWebJobsStorage__clientId : identityClientId
AzureWebJobsStorage__credential : 'managedidentity'
APPLICATIONINSIGHTS_AUTHENTICATION_STRING: applicationInsightsIdentity
+ AzureMonitorExporter__credential: 'managedidentity'
+ AzureMonitorExporter__clientId: identityClientId
DTS_CONNECTION_STRING: 'Endpoint=${dtsURL};Authentication=ManagedIdentity;ClientID=${identityClientId}'
TASKHUB_NAME: taskHubName
- AZURE_CLIENT_ID: identityClientId
})
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/core/host/functions-flexconsumption.bicep b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/core/host/functions-flexconsumption.bicep
index d6a5e632..650fc2c5 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/core/host/functions-flexconsumption.bicep
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/core/host/functions-flexconsumption.bicep
@@ -14,10 +14,10 @@ param identityId string
// Runtime Properties
@allowed([
- 'dotnet-isolated', 'node', 'python', 'java', 'powershell', 'custom'
+ 'dotnet-isolated'
])
param runtimeName string
-@allowed(['3.10', '3.11', '7.4', '8.0', '10', '11', '17', '20'])
+@allowed(['10.0', '11.0'])
param runtimeVersion string
param kind string = 'functionapp,linux'
diff --git a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/main.bicep b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/main.bicep
index 7cccab77..b210c4d6 100644
--- a/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/main.bicep
+++ b/samples/durable-functions/dotnet/LargePayloadFanOutFanIn/infra/main.bicep
@@ -118,7 +118,7 @@ module durableFunction './app/durable-function.bicep' = {
applicationInsightsName: monitoring.outputs.applicationInsightsName
appServicePlanId: appServicePlan.outputs.id
runtimeName: 'dotnet-isolated'
- runtimeVersion: '8.0'
+ runtimeVersion: '10.0'
storageAccountName: storage.outputs.name
deploymentStorageContainerName: deploymentStorageContainerName
identityId: durableFunctionUserAssignedIdentity.outputs.identityId
diff --git a/samples/durable-functions/dotnet/Saga/DurableFunctionsSaga.csproj b/samples/durable-functions/dotnet/Saga/DurableFunctionsSaga.csproj
index 2df2669c..86e6916f 100644
--- a/samples/durable-functions/dotnet/Saga/DurableFunctionsSaga.csproj
+++ b/samples/durable-functions/dotnet/Saga/DurableFunctionsSaga.csproj
@@ -1,6 +1,6 @@
- net8.0
+ net10.0
v4
Exe
enable
@@ -9,16 +9,20 @@
-
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
diff --git a/samples/durable-functions/dotnet/Saga/Functions/HttpTriggers.cs b/samples/durable-functions/dotnet/Saga/Functions/HttpTriggers.cs
index 8511f6e6..c363542a 100644
--- a/samples/durable-functions/dotnet/Saga/Functions/HttpTriggers.cs
+++ b/samples/durable-functions/dotnet/Saga/Functions/HttpTriggers.cs
@@ -21,7 +21,7 @@ public HttpTriggers(ILogger logger)
[Function("StartOrderProcessing")]
public async Task StartOrderProcessing(
- [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "orders")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "post", Route = "orders")] HttpRequestData req,
[DurableClient] DurableTaskClient client)
{
_logger.LogInformation("Processing order request");
@@ -72,7 +72,7 @@ await response.WriteAsJsonAsync(new
[Function("GetOrderStatus")]
public async Task GetOrderStatus(
- [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "orders/{instanceId}")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "get", Route = "orders/{instanceId}")] HttpRequestData req,
string instanceId,
[DurableClient] DurableTaskClient client)
{
@@ -99,7 +99,7 @@ await response.WriteAsJsonAsync(new
[Function("TerminateOrder")]
public async Task TerminateOrder(
- [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "orders/{instanceId}/terminate")] HttpRequestData req,
+ [HttpTrigger(AuthorizationLevel.Function, "post", Route = "orders/{instanceId}/terminate")] HttpRequestData req,
string instanceId,
[DurableClient] DurableTaskClient client)
{
diff --git a/samples/durable-functions/dotnet/Saga/Program.cs b/samples/durable-functions/dotnet/Saga/Program.cs
index cc057033..62b93163 100644
--- a/samples/durable-functions/dotnet/Saga/Program.cs
+++ b/samples/durable-functions/dotnet/Saga/Program.cs
@@ -1,8 +1,32 @@
+using Azure.Monitor.OpenTelemetry.Exporter;
+using Microsoft.Azure.Functions.Worker.OpenTelemetry;
+using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
+ .ConfigureServices((context, services) =>
+ {
+ string? connectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
+ if (!string.IsNullOrWhiteSpace(connectionString))
+ {
+ services.AddAzureClientsCore();
+ services.AddOptions()
+ .Configure((options, factory) =>
+ {
+ options.ConnectionString = connectionString;
+ var credentialSettings = context.Configuration.GetSection("AzureMonitorExporter");
+ if (!string.IsNullOrWhiteSpace(context.Configuration["AzureMonitorExporter:credential"]))
+ {
+ options.Credential = factory.CreateTokenCredential(credentialSettings);
+ }
+ });
+ services.AddOpenTelemetry()
+ .UseFunctionsWorkerDefaults()
+ .UseAzureMonitorExporter();
+ }
+ })
.Build();
host.Run();
diff --git a/samples/durable-functions/dotnet/Saga/README.md b/samples/durable-functions/dotnet/Saga/README.md
index 9ab41a78..34004409 100644
--- a/samples/durable-functions/dotnet/Saga/README.md
+++ b/samples/durable-functions/dotnet/Saga/README.md
@@ -1,6 +1,6 @@
-# Order Processing with Saga Pattern in .NET 8 Durable Functions
+# Order Processing with Saga Pattern in .NET 10 Durable Functions
-This project demonstrates an implementation of the Saga pattern using .NET 8 and Azure Durable Functions. The Saga pattern is a failure management pattern that helps maintain data consistency across distributed business processes by defining compensating actions for each step in the workflow.
+This project demonstrates an implementation of the Saga pattern using .NET 10 and Azure Durable Functions. The Saga pattern is a failure management pattern that helps maintain data consistency across distributed business processes by defining compensating actions for each step in the workflow.
## Overview
@@ -65,7 +65,7 @@ For each business operation, we define a corresponding compensation:
### Prerequisites
-1. [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
+1. [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
2. [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local) (v4.x)
3. [Docker](https://www.docker.com/products/docker-desktop/) for running the DTS emulator
@@ -166,6 +166,10 @@ The emulator simulates a scheduler and taskhub in a Docker container, making it
- The approval step also fails 25% of the time (by design)
- When it fails, you'll see the compensation actions run in reverse order
+## Telemetry
+
+The Functions host uses OpenTelemetry. When `APPLICATIONINSIGHTS_CONNECTION_STRING` is set, the worker exports to Azure Monitor. For user-assigned managed identity authentication, set `AzureMonitorExporter__credential` to `managedidentity` and `AzureMonitorExporter__clientId` to the identity's client ID, and grant that identity the Monitoring Metrics Publisher role on Application Insights. Unless `AzureMonitorExporter__credential` is explicitly set, the exporter uses connection-string authentication. Without the connection string, the worker does not export.
+
## Project Structure
- **Saga/Compensations.cs** - Core compensation management logic
@@ -176,6 +180,20 @@ The emulator simulates a scheduler and taskhub in a Docker container, making it
## API Reference
+All three endpoints require a function or host key in Azure. Core Tools skips key enforcement locally by default, so the local examples and `test.http` work without a key. Use `func start --enableAuth` to exercise enforcement locally.
+
+Use a non-admin host (function) key across the starter, status, and termination endpoints; a function-specific starter key does not authorize the other functions:
+
+```bash
+FUNCTION_KEY=$(az functionapp keys list \
+ --resource-group "$AZURE_RESOURCE_GROUP" \
+ --name "$AZURE_FUNCTION_NAME" --query functionKeys.default --output tsv)
+curl -H "x-functions-key: ${FUNCTION_KEY}" \
+ "https://${AZURE_FUNCTION_NAME}.azurewebsites.net/api/orders/${INSTANCE_ID}"
+```
+
+Keep the key out of source control, logs, shared output, and browser code. Do not use the master key. Keys grant application access, not order ownership or per-user authorization. The relative status URL returned by the starter does not embed a key: send the header on every status or termination request. Managed identity for DTS and telemetry is unchanged.
+
- **POST /api/orders** - Start a new order processing workflow
- Body: Order details (customerId, productId, quantity, amount)
- Returns: Instance ID and status URL
diff --git a/samples/durable-functions/dotnet/Saga/host.json b/samples/durable-functions/dotnet/Saga/host.json
index c0aff92f..71ed6982 100644
--- a/samples/durable-functions/dotnet/Saga/host.json
+++ b/samples/durable-functions/dotnet/Saga/host.json
@@ -1,5 +1,6 @@
{
"version": "2.0",
+ "telemetryMode": "OpenTelemetry",
"extensions": {
"durableTask": {
"hubName": "default",
diff --git a/samples/durable-functions/dotnet/Saga/test.http b/samples/durable-functions/dotnet/Saga/test.http
index a8215a05..2ce28819 100644
--- a/samples/durable-functions/dotnet/Saga/test.http
+++ b/samples/durable-functions/dotnet/Saga/test.http
@@ -1,6 +1,11 @@
+# For Azure or Core Tools --enableAuth, set this to a non-admin host key.
+# Leave empty for the default local Core Tools host. Do not commit real keys.
+@functionKey =
+
# Start a new order processing workflow
# This will trigger the Saga pattern and show compensation in action
POST http://localhost:7071/api/orders
+x-functions-key: {{functionKey}}
Content-Type: application/json
{
@@ -15,6 +20,8 @@ Content-Type: application/json
### Check the status of an order
GET http://localhost:7071/api/orders/{{instanceId}}
+x-functions-key: {{functionKey}}
### Terminate a running workflow if needed
POST http://localhost:7071/api/orders/{{instanceId}}/terminate
+x-functions-key: {{functionKey}}