$npx -y skills add managedcode/dotnet-skills --skill azure-functionsBuild, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR: working on Azure Functions in .NET; migrating from the in-process model to the isolated worker model; adding Durable Funct
| 1 | # Azure Functions for .NET |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - working on Azure Functions in .NET |
| 6 | - migrating from the in-process model to the isolated worker model |
| 7 | - adding Durable Functions, bindings, or host configuration |
| 8 | |
| 9 | ## Documentation |
| 10 | |
| 11 | - [Guide for running C# Azure Functions in an isolated worker process](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide) |
| 12 | - [Differences between in-process and isolated worker process](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-differences) |
| 13 | - [Migrate C# app from in-process to isolated worker model](https://learn.microsoft.com/en-us/azure/azure-functions/migrate-dotnet-to-isolated-model) |
| 14 | - [Durable Functions overview](https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview) |
| 15 | - [Durable Functions best practices and diagnostic tools](https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-best-practice-reference) |
| 16 | |
| 17 | ### References |
| 18 | |
| 19 | - [Patterns](references/patterns.md) - Isolated worker patterns, Durable Functions patterns, advanced binding patterns |
| 20 | - [Anti-Patterns](references/anti-patterns.md) - Common Azure Functions mistakes and how to avoid them |
| 21 | |
| 22 | ## Workflow |
| 23 | |
| 24 | 1. **Use isolated worker model for all new work:** |
| 25 | - In-process model reaches end of support on November 10, 2026 |
| 26 | - Runtime v1.x ends support on September 14, 2026 |
| 27 | - Target .NET 8+ for longest support window |
| 28 | |
| 29 | 2. **Detect current project shape:** |
| 30 | - Target framework and runtime version |
| 31 | - Worker model (isolated vs in-process) |
| 32 | - Binding packages and host configuration |
| 33 | |
| 34 | 3. **Use standard .NET patterns in isolated model:** |
| 35 | - Normal dependency injection |
| 36 | - Middleware pipeline |
| 37 | - `IOptions<T>` for configuration |
| 38 | - `ILogger<T>` for logging |
| 39 | |
| 40 | 4. **For Durable Functions:** |
| 41 | - Validate orchestration determinism constraints |
| 42 | - Handle replay behavior correctly |
| 43 | - Use typed activity patterns |
| 44 | |
| 45 | 5. **Verify both local and deployment behavior.** |
| 46 | |
| 47 | ## Isolated Worker Model Setup |
| 48 | |
| 49 | ### Basic Function with DI |
| 50 | ```csharp |
| 51 | // Program.cs |
| 52 | var host = new HostBuilder() |
| 53 | .ConfigureFunctionsWebApplication() |
| 54 | .ConfigureServices(services => |
| 55 | { |
| 56 | services.AddApplicationInsightsTelemetryWorkerService(); |
| 57 | services.ConfigureFunctionsApplicationInsights(); |
| 58 | services.AddSingleton<IMyService, MyService>(); |
| 59 | }) |
| 60 | .Build(); |
| 61 | |
| 62 | host.Run(); |
| 63 | ``` |
| 64 | |
| 65 | ### HTTP Trigger Function |
| 66 | ```csharp |
| 67 | public class HttpFunctions(ILogger<HttpFunctions> logger, IMyService myService) |
| 68 | { |
| 69 | [Function("GetItems")] |
| 70 | public async Task<IActionResult> GetItems( |
| 71 | [HttpTrigger(AuthorizationLevel.Function, "get", Route = "items")] HttpRequest req) |
| 72 | { |
| 73 | logger.LogInformation("Processing GetItems request"); |
| 74 | var items = await myService.GetItemsAsync(); |
| 75 | return new OkObjectResult(items); |
| 76 | } |
| 77 | } |
| 78 | ``` |
| 79 | |
| 80 | ### Queue Trigger with Options |
| 81 | ```csharp |
| 82 | public class QueueFunctions(ILogger<QueueFunctions> logger, IOptions<ProcessingOptions> options) |
| 83 | { |
| 84 | [Function("ProcessMessage")] |
| 85 | public async Task ProcessMessage( |
| 86 | [QueueTrigger("myqueue", Connection = "AzureWebJobsStorage")] string message) |
| 87 | { |
| 88 | logger.LogInformation("Processing message: {Message}", message); |
| 89 | // Process with retry policy from options |
| 90 | } |
| 91 | } |
| 92 | ``` |
| 93 | |
| 94 | ## Middleware Pattern |
| 95 | |
| 96 | ### Custom Middleware |
| 97 | ```csharp |
| 98 | // Program.cs |
| 99 | var host = new HostBuilder() |
| 100 | .ConfigureFunctionsWebApplication(builder => |
| 101 | { |
| 102 | builder.UseMiddleware<ExceptionHandlingMiddleware>(); |
| 103 | builder.UseMiddleware<CorrelationIdMiddleware>(); |
| 104 | }) |
| 105 | .Build(); |
| 106 | |
| 107 | // CorrelationIdMiddleware.cs |
| 108 | public class CorrelationIdMiddleware : IFunctionsWorkerMiddleware |
| 109 | { |
| 110 | public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next) |
| 111 | { |
| 112 | var correlationId = context.Features.Get<IHttpRequestFeature>()?.Headers["X-Correlation-Id"] |
| 113 | ?? Guid.NewGuid().ToString(); |
| 114 | |
| 115 | context.Items["CorrelationId"] = correlationId; |
| 116 | |
| 117 | await next(context); |
| 118 | } |
| 119 | } |
| 120 | ``` |
| 121 | |
| 122 | ## Durable Functions Patterns |
| 123 | |
| 124 | ### Function Chaining |
| 125 | ```csharp |
| 126 | [Function(nameof(ChainOrchestrator))] |
| 127 | public static async Task<string> ChainOrchestrator( |
| 128 | [OrchestrationTrigger] TaskOrchestrationContext context) |
| 129 | { |
| 130 | var result1 = await context.CallActivityAsync<string>(name |