opencode-skills-collection 1.0.185 → 1.0.187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/.antigravity-install-manifest.json +5 -1
- package/bundled-skills/3d-web-experience/SKILL.md +152 -37
- package/bundled-skills/agent-evaluation/SKILL.md +1088 -26
- package/bundled-skills/agent-memory-systems/SKILL.md +1037 -25
- package/bundled-skills/agent-tool-builder/SKILL.md +668 -16
- package/bundled-skills/ai-agents-architect/SKILL.md +271 -31
- package/bundled-skills/ai-product/SKILL.md +716 -26
- package/bundled-skills/ai-wrapper-product/SKILL.md +450 -44
- package/bundled-skills/algolia-search/SKILL.md +867 -15
- package/bundled-skills/autonomous-agents/SKILL.md +1033 -26
- package/bundled-skills/aws-serverless/SKILL.md +1046 -35
- package/bundled-skills/azure-functions/SKILL.md +1318 -19
- package/bundled-skills/browser-automation/SKILL.md +1065 -28
- package/bundled-skills/browser-extension-builder/SKILL.md +159 -32
- package/bundled-skills/bullmq-specialist/SKILL.md +347 -16
- package/bundled-skills/clerk-auth/SKILL.md +796 -15
- package/bundled-skills/computer-use-agents/SKILL.md +1870 -28
- package/bundled-skills/context-window-management/SKILL.md +271 -18
- package/bundled-skills/conversation-memory/SKILL.md +453 -24
- package/bundled-skills/crewai/SKILL.md +252 -46
- package/bundled-skills/discord-bot-architect/SKILL.md +1207 -34
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/users/bundles.md +1 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/email-systems/SKILL.md +646 -26
- package/bundled-skills/faf-expert/SKILL.md +221 -0
- package/bundled-skills/faf-wizard/SKILL.md +252 -0
- package/bundled-skills/file-uploads/SKILL.md +212 -11
- package/bundled-skills/firebase/SKILL.md +646 -16
- package/bundled-skills/gcp-cloud-run/SKILL.md +1117 -32
- package/bundled-skills/graphql/SKILL.md +1026 -27
- package/bundled-skills/hubspot-integration/SKILL.md +804 -19
- package/bundled-skills/idea-darwin/SKILL.md +120 -0
- package/bundled-skills/inngest/SKILL.md +431 -16
- package/bundled-skills/interactive-portfolio/SKILL.md +342 -44
- package/bundled-skills/langfuse/SKILL.md +296 -41
- package/bundled-skills/langgraph/SKILL.md +259 -50
- package/bundled-skills/micro-saas-launcher/SKILL.md +343 -44
- package/bundled-skills/neon-postgres/SKILL.md +572 -15
- package/bundled-skills/nextjs-supabase-auth/SKILL.md +269 -21
- package/bundled-skills/notion-template-business/SKILL.md +371 -44
- package/bundled-skills/personal-tool-builder/SKILL.md +537 -44
- package/bundled-skills/plaid-fintech/SKILL.md +825 -19
- package/bundled-skills/prompt-caching/SKILL.md +438 -25
- package/bundled-skills/rag-engineer/SKILL.md +271 -29
- package/bundled-skills/salesforce-development/SKILL.md +912 -19
- package/bundled-skills/satori/SKILL.md +54 -0
- package/bundled-skills/scroll-experience/SKILL.md +381 -44
- package/bundled-skills/segment-cdp/SKILL.md +817 -19
- package/bundled-skills/shopify-apps/SKILL.md +1475 -19
- package/bundled-skills/slack-bot-builder/SKILL.md +1162 -28
- package/bundled-skills/telegram-bot-builder/SKILL.md +152 -37
- package/bundled-skills/telegram-mini-app/SKILL.md +445 -44
- package/bundled-skills/trigger-dev/SKILL.md +916 -27
- package/bundled-skills/twilio-communications/SKILL.md +1310 -28
- package/bundled-skills/upstash-qstash/SKILL.md +898 -27
- package/bundled-skills/vercel-deployment/SKILL.md +637 -39
- package/bundled-skills/viral-generator-builder/SKILL.md +132 -37
- package/bundled-skills/voice-agents/SKILL.md +937 -27
- package/bundled-skills/voice-ai-development/SKILL.md +375 -46
- package/bundled-skills/workflow-automation/SKILL.md +982 -29
- package/bundled-skills/zapier-make-patterns/SKILL.md +772 -27
- package/package.json +1 -1
|
@@ -1,47 +1,1346 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: azure-functions
|
|
3
|
-
description:
|
|
3
|
+
description: Expert patterns for Azure Functions development including isolated
|
|
4
|
+
worker model, Durable Functions orchestration, cold start optimization, and
|
|
5
|
+
production patterns. Covers .NET, Python, and Node.js programming models.
|
|
4
6
|
risk: none
|
|
5
|
-
source:
|
|
6
|
-
date_added:
|
|
7
|
+
source: vibeship-spawner-skills (Apache 2.0)
|
|
8
|
+
date_added: 2026-02-27
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
# Azure Functions
|
|
10
12
|
|
|
13
|
+
Expert patterns for Azure Functions development including isolated worker model,
|
|
14
|
+
Durable Functions orchestration, cold start optimization, and production patterns.
|
|
15
|
+
Covers .NET, Python, and Node.js programming models.
|
|
16
|
+
|
|
11
17
|
## Patterns
|
|
12
18
|
|
|
13
19
|
### Isolated Worker Model (.NET)
|
|
14
20
|
|
|
15
21
|
Modern .NET execution model with process isolation
|
|
16
22
|
|
|
23
|
+
**When to use**: Building new .NET Azure Functions apps
|
|
24
|
+
|
|
25
|
+
### Template
|
|
26
|
+
|
|
27
|
+
// Program.cs - Isolated Worker Model
|
|
28
|
+
using Microsoft.Azure.Functions.Worker;
|
|
29
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
30
|
+
using Microsoft.Extensions.Hosting;
|
|
31
|
+
|
|
32
|
+
var host = new HostBuilder()
|
|
33
|
+
.ConfigureFunctionsWorkerDefaults()
|
|
34
|
+
.ConfigureServices(services =>
|
|
35
|
+
{
|
|
36
|
+
// Add Application Insights
|
|
37
|
+
services.AddApplicationInsightsTelemetryWorkerService();
|
|
38
|
+
services.ConfigureFunctionsApplicationInsights();
|
|
39
|
+
|
|
40
|
+
// Add HttpClientFactory (prevents socket exhaustion)
|
|
41
|
+
services.AddHttpClient();
|
|
42
|
+
|
|
43
|
+
// Add your services
|
|
44
|
+
services.AddSingleton<IMyService, MyService>();
|
|
45
|
+
})
|
|
46
|
+
.Build();
|
|
47
|
+
|
|
48
|
+
host.Run();
|
|
49
|
+
|
|
50
|
+
// HttpTriggerFunction.cs
|
|
51
|
+
using Microsoft.Azure.Functions.Worker;
|
|
52
|
+
using Microsoft.Azure.Functions.Worker.Http;
|
|
53
|
+
using Microsoft.Extensions.Logging;
|
|
54
|
+
|
|
55
|
+
public class HttpTriggerFunction
|
|
56
|
+
{
|
|
57
|
+
private readonly ILogger<HttpTriggerFunction> _logger;
|
|
58
|
+
private readonly IMyService _service;
|
|
59
|
+
|
|
60
|
+
public HttpTriggerFunction(
|
|
61
|
+
ILogger<HttpTriggerFunction> logger,
|
|
62
|
+
IMyService service)
|
|
63
|
+
{
|
|
64
|
+
_logger = logger;
|
|
65
|
+
_service = service;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[Function("HttpTrigger")]
|
|
69
|
+
public async Task<HttpResponseData> Run(
|
|
70
|
+
[HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
|
|
71
|
+
{
|
|
72
|
+
_logger.LogInformation("Processing request");
|
|
73
|
+
|
|
74
|
+
try
|
|
75
|
+
{
|
|
76
|
+
var result = await _service.ProcessAsync(req);
|
|
77
|
+
|
|
78
|
+
var response = req.CreateResponse(HttpStatusCode.OK);
|
|
79
|
+
await response.WriteAsJsonAsync(result);
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
catch (Exception ex)
|
|
83
|
+
{
|
|
84
|
+
_logger.LogError(ex, "Error processing request");
|
|
85
|
+
var response = req.CreateResponse(HttpStatusCode.InternalServerError);
|
|
86
|
+
await response.WriteAsJsonAsync(new { error = "Internal server error" });
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
### Notes
|
|
93
|
+
|
|
94
|
+
- In-process model deprecated November 2026
|
|
95
|
+
- Isolated worker supports .NET 8, 9, 10, and .NET Framework
|
|
96
|
+
- Full dependency injection support
|
|
97
|
+
- Custom middleware support
|
|
98
|
+
|
|
17
99
|
### Node.js v4 Programming Model
|
|
18
100
|
|
|
19
101
|
Modern code-centric approach for TypeScript/JavaScript
|
|
20
102
|
|
|
103
|
+
**When to use**: Building Node.js Azure Functions
|
|
104
|
+
|
|
105
|
+
### Template
|
|
106
|
+
|
|
107
|
+
// src/functions/httpTrigger.ts
|
|
108
|
+
import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";
|
|
109
|
+
|
|
110
|
+
export async function httpTrigger(
|
|
111
|
+
request: HttpRequest,
|
|
112
|
+
context: InvocationContext
|
|
113
|
+
): Promise<HttpResponseInit> {
|
|
114
|
+
context.log(`Http function processed request for url "${request.url}"`);
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const name = request.query.get("name") || (await request.text()) || "world";
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
status: 200,
|
|
121
|
+
jsonBody: { message: `Hello, ${name}!` }
|
|
122
|
+
};
|
|
123
|
+
} catch (error) {
|
|
124
|
+
context.error("Error processing request:", error);
|
|
125
|
+
return {
|
|
126
|
+
status: 500,
|
|
127
|
+
jsonBody: { error: "Internal server error" }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Register function with app object
|
|
133
|
+
app.http("httpTrigger", {
|
|
134
|
+
methods: ["GET", "POST"],
|
|
135
|
+
authLevel: "function",
|
|
136
|
+
handler: httpTrigger
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Timer trigger example
|
|
140
|
+
app.timer("timerTrigger", {
|
|
141
|
+
schedule: "0 */5 * * * *", // Every 5 minutes
|
|
142
|
+
handler: async (myTimer, context) => {
|
|
143
|
+
context.log("Timer function executed at:", new Date().toISOString());
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Blob trigger example
|
|
148
|
+
app.storageBlob("blobTrigger", {
|
|
149
|
+
path: "samples-workitems/{name}",
|
|
150
|
+
connection: "AzureWebJobsStorage",
|
|
151
|
+
handler: async (blob, context) => {
|
|
152
|
+
context.log(`Blob trigger processing: ${context.triggerMetadata.name}`);
|
|
153
|
+
context.log(`Blob size: ${blob.length} bytes`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
### Notes
|
|
158
|
+
|
|
159
|
+
- v4 model is code-centric, no function.json files
|
|
160
|
+
- Uses app object similar to Express.js
|
|
161
|
+
- TypeScript first-class support
|
|
162
|
+
- All triggers registered in code
|
|
163
|
+
|
|
21
164
|
### Python v2 Programming Model
|
|
22
165
|
|
|
23
166
|
Decorator-based approach for Python functions
|
|
24
167
|
|
|
25
|
-
|
|
168
|
+
**When to use**: Building Python Azure Functions
|
|
169
|
+
|
|
170
|
+
### Template
|
|
171
|
+
|
|
172
|
+
# function_app.py
|
|
173
|
+
import azure.functions as func
|
|
174
|
+
import logging
|
|
175
|
+
import json
|
|
176
|
+
|
|
177
|
+
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
|
|
178
|
+
|
|
179
|
+
@app.route(route="hello", methods=["GET", "POST"])
|
|
180
|
+
async def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
|
|
181
|
+
logging.info("Python HTTP trigger function processed a request.")
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
name = req.params.get("name")
|
|
185
|
+
if not name:
|
|
186
|
+
try:
|
|
187
|
+
req_body = req.get_json()
|
|
188
|
+
name = req_body.get("name")
|
|
189
|
+
except ValueError:
|
|
190
|
+
pass
|
|
191
|
+
|
|
192
|
+
if name:
|
|
193
|
+
return func.HttpResponse(
|
|
194
|
+
json.dumps({"message": f"Hello, {name}!"}),
|
|
195
|
+
mimetype="application/json"
|
|
196
|
+
)
|
|
197
|
+
else:
|
|
198
|
+
return func.HttpResponse(
|
|
199
|
+
json.dumps({"message": "Hello, World!"}),
|
|
200
|
+
mimetype="application/json"
|
|
201
|
+
)
|
|
202
|
+
except Exception as e:
|
|
203
|
+
logging.error(f"Error processing request: {str(e)}")
|
|
204
|
+
return func.HttpResponse(
|
|
205
|
+
json.dumps({"error": "Internal server error"}),
|
|
206
|
+
status_code=500,
|
|
207
|
+
mimetype="application/json"
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
@app.timer_trigger(schedule="0 */5 * * * *", arg_name="myTimer")
|
|
211
|
+
def timer_trigger(myTimer: func.TimerRequest) -> None:
|
|
212
|
+
logging.info("Timer trigger executed")
|
|
213
|
+
|
|
214
|
+
@app.blob_trigger(arg_name="myblob", path="samples-workitems/{name}",
|
|
215
|
+
connection="AzureWebJobsStorage")
|
|
216
|
+
def blob_trigger(myblob: func.InputStream):
|
|
217
|
+
logging.info(f"Blob trigger: {myblob.name}, Size: {myblob.length} bytes")
|
|
218
|
+
|
|
219
|
+
@app.queue_trigger(arg_name="msg", queue_name="myqueue",
|
|
220
|
+
connection="AzureWebJobsStorage")
|
|
221
|
+
def queue_trigger(msg: func.QueueMessage) -> None:
|
|
222
|
+
logging.info(f"Queue message: {msg.get_body().decode('utf-8')}")
|
|
223
|
+
|
|
224
|
+
### Notes
|
|
225
|
+
|
|
226
|
+
- v2 model uses decorators, no function.json files
|
|
227
|
+
- Python runs out-of-process (always isolated)
|
|
228
|
+
- Linux-based hosting required for Python
|
|
229
|
+
- Async functions supported
|
|
230
|
+
|
|
231
|
+
### Durable Functions - Function Chaining
|
|
232
|
+
|
|
233
|
+
Sequential execution with state persistence
|
|
234
|
+
|
|
235
|
+
**When to use**: Need sequential workflow with automatic retry
|
|
236
|
+
|
|
237
|
+
### Template
|
|
238
|
+
|
|
239
|
+
// C# Isolated Worker - Function Chaining
|
|
240
|
+
using Microsoft.Azure.Functions.Worker;
|
|
241
|
+
using Microsoft.DurableTask;
|
|
242
|
+
using Microsoft.DurableTask.Client;
|
|
243
|
+
|
|
244
|
+
public class OrderWorkflow
|
|
245
|
+
{
|
|
246
|
+
[Function("OrderOrchestrator")]
|
|
247
|
+
public static async Task<OrderResult> RunOrchestrator(
|
|
248
|
+
[OrchestrationTrigger] TaskOrchestrationContext context)
|
|
249
|
+
{
|
|
250
|
+
var order = context.GetInput<Order>();
|
|
251
|
+
|
|
252
|
+
// Functions execute sequentially, state persisted between each
|
|
253
|
+
var validated = await context.CallActivityAsync<ValidatedOrder>(
|
|
254
|
+
"ValidateOrder", order);
|
|
255
|
+
|
|
256
|
+
var payment = await context.CallActivityAsync<PaymentResult>(
|
|
257
|
+
"ProcessPayment", validated);
|
|
258
|
+
|
|
259
|
+
var shipped = await context.CallActivityAsync<ShippingResult>(
|
|
260
|
+
"ShipOrder", new ShipRequest { Order = validated, Payment = payment });
|
|
261
|
+
|
|
262
|
+
var notification = await context.CallActivityAsync<bool>(
|
|
263
|
+
"SendNotification", shipped);
|
|
264
|
+
|
|
265
|
+
return new OrderResult
|
|
266
|
+
{
|
|
267
|
+
OrderId = order.Id,
|
|
268
|
+
Status = "Completed",
|
|
269
|
+
TrackingNumber = shipped.TrackingNumber
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
[Function("ValidateOrder")]
|
|
274
|
+
public static async Task<ValidatedOrder> ValidateOrder(
|
|
275
|
+
[ActivityTrigger] Order order, FunctionContext context)
|
|
276
|
+
{
|
|
277
|
+
var logger = context.GetLogger<OrderWorkflow>();
|
|
278
|
+
logger.LogInformation("Validating order {OrderId}", order.Id);
|
|
279
|
+
|
|
280
|
+
// Validation logic...
|
|
281
|
+
return new ValidatedOrder { /* ... */ };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
[Function("ProcessPayment")]
|
|
285
|
+
public static async Task<PaymentResult> ProcessPayment(
|
|
286
|
+
[ActivityTrigger] ValidatedOrder order, FunctionContext context)
|
|
287
|
+
{
|
|
288
|
+
// Payment processing with built-in retry...
|
|
289
|
+
return new PaymentResult { /* ... */ };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
[Function("OrderWorkflow_HttpStart")]
|
|
293
|
+
public static async Task<HttpResponseData> HttpStart(
|
|
294
|
+
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
|
|
295
|
+
[DurableClient] DurableTaskClient client,
|
|
296
|
+
FunctionContext context)
|
|
297
|
+
{
|
|
298
|
+
var order = await req.ReadFromJsonAsync<Order>();
|
|
299
|
+
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
|
|
300
|
+
"OrderOrchestrator", order);
|
|
301
|
+
|
|
302
|
+
return client.CreateCheckStatusResponse(req, instanceId);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
### Notes
|
|
307
|
+
|
|
308
|
+
- State automatically persisted between activities
|
|
309
|
+
- Automatic retry on transient failures
|
|
310
|
+
- Survives process restarts
|
|
311
|
+
- Built-in status endpoint for monitoring
|
|
312
|
+
|
|
313
|
+
### Durable Functions - Fan-Out/Fan-In
|
|
314
|
+
|
|
315
|
+
Parallel execution with result aggregation
|
|
316
|
+
|
|
317
|
+
**When to use**: Processing multiple items in parallel
|
|
318
|
+
|
|
319
|
+
### Template
|
|
320
|
+
|
|
321
|
+
// C# Isolated Worker - Fan-Out/Fan-In
|
|
322
|
+
using Microsoft.Azure.Functions.Worker;
|
|
323
|
+
using Microsoft.DurableTask;
|
|
324
|
+
|
|
325
|
+
public class ParallelProcessing
|
|
326
|
+
{
|
|
327
|
+
[Function("ProcessImagesOrchestrator")]
|
|
328
|
+
public static async Task<ProcessingResult> RunOrchestrator(
|
|
329
|
+
[OrchestrationTrigger] TaskOrchestrationContext context)
|
|
330
|
+
{
|
|
331
|
+
var images = context.GetInput<List<string>>();
|
|
332
|
+
|
|
333
|
+
// Fan-out: Start all tasks in parallel
|
|
334
|
+
var tasks = images.Select(image =>
|
|
335
|
+
context.CallActivityAsync<ImageResult>("ProcessImage", image));
|
|
336
|
+
|
|
337
|
+
// Fan-in: Wait for all tasks to complete
|
|
338
|
+
var results = await Task.WhenAll(tasks);
|
|
339
|
+
|
|
340
|
+
// Aggregate results
|
|
341
|
+
var successful = results.Count(r => r.Success);
|
|
342
|
+
var failed = results.Count(r => !r.Success);
|
|
343
|
+
|
|
344
|
+
return new ProcessingResult
|
|
345
|
+
{
|
|
346
|
+
TotalProcessed = results.Length,
|
|
347
|
+
Successful = successful,
|
|
348
|
+
Failed = failed,
|
|
349
|
+
Results = results.ToList()
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
[Function("ProcessImage")]
|
|
354
|
+
public static async Task<ImageResult> ProcessImage(
|
|
355
|
+
[ActivityTrigger] string imageUrl, FunctionContext context)
|
|
356
|
+
{
|
|
357
|
+
var logger = context.GetLogger<ParallelProcessing>();
|
|
358
|
+
logger.LogInformation("Processing image: {Url}", imageUrl);
|
|
359
|
+
|
|
360
|
+
try
|
|
361
|
+
{
|
|
362
|
+
// Image processing logic...
|
|
363
|
+
await Task.Delay(1000); // Simulated work
|
|
364
|
+
|
|
365
|
+
return new ImageResult
|
|
366
|
+
{
|
|
367
|
+
Url = imageUrl,
|
|
368
|
+
Success = true,
|
|
369
|
+
ProcessedUrl = $"processed-{imageUrl}"
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
catch (Exception ex)
|
|
373
|
+
{
|
|
374
|
+
logger.LogError(ex, "Failed to process {Url}", imageUrl);
|
|
375
|
+
return new ImageResult { Url = imageUrl, Success = false };
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Python equivalent
|
|
380
|
+
// @app.orchestration_trigger(context_name="context")
|
|
381
|
+
// def process_images_orchestrator(context: df.DurableOrchestrationContext):
|
|
382
|
+
// images = context.get_input()
|
|
383
|
+
//
|
|
384
|
+
// # Fan-out: Create parallel tasks
|
|
385
|
+
// tasks = [context.call_activity("ProcessImage", img) for img in images]
|
|
386
|
+
//
|
|
387
|
+
// # Fan-in: Wait for all
|
|
388
|
+
// results = yield context.task_all(tasks)
|
|
389
|
+
//
|
|
390
|
+
// return {"processed": len(results), "results": results}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
### Notes
|
|
394
|
+
|
|
395
|
+
- Parallel execution for independent tasks
|
|
396
|
+
- Results aggregated when all complete
|
|
397
|
+
- Memory efficient - only stores task IDs
|
|
398
|
+
- Up to thousands of parallel activities
|
|
399
|
+
|
|
400
|
+
### Cold Start Optimization
|
|
401
|
+
|
|
402
|
+
Minimize cold start latency in production
|
|
403
|
+
|
|
404
|
+
**When to use**: Need fast response times in production
|
|
405
|
+
|
|
406
|
+
### Template
|
|
407
|
+
|
|
408
|
+
// 1. Use Premium Plan with pre-warmed instances
|
|
409
|
+
// host.json
|
|
410
|
+
{
|
|
411
|
+
"version": "2.0",
|
|
412
|
+
"extensions": {
|
|
413
|
+
"durableTask": {
|
|
414
|
+
"hubName": "MyTaskHub"
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
"functionTimeout": "00:30:00"
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 2. Add warmup trigger (Premium Plan)
|
|
421
|
+
[Function("Warmup")]
|
|
422
|
+
public static void Warmup(
|
|
423
|
+
[WarmupTrigger] object warmupContext,
|
|
424
|
+
FunctionContext context)
|
|
425
|
+
{
|
|
426
|
+
var logger = context.GetLogger("Warmup");
|
|
427
|
+
logger.LogInformation("Warmup trigger executed - initializing dependencies");
|
|
428
|
+
|
|
429
|
+
// Pre-initialize expensive resources
|
|
430
|
+
// Database connections, HttpClients, etc.
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 3. Use static/singleton clients with DI
|
|
434
|
+
public class Startup
|
|
435
|
+
{
|
|
436
|
+
public void ConfigureServices(IServiceCollection services)
|
|
437
|
+
{
|
|
438
|
+
// HttpClientFactory prevents socket exhaustion
|
|
439
|
+
services.AddHttpClient<IMyApiClient, MyApiClient>(client =>
|
|
440
|
+
{
|
|
441
|
+
client.BaseAddress = new Uri("https://api.example.com");
|
|
442
|
+
client.Timeout = TimeSpan.FromSeconds(30);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// Singleton for expensive initialization
|
|
446
|
+
services.AddSingleton<IExpensiveService>(sp =>
|
|
447
|
+
{
|
|
448
|
+
// Initialize once, reuse across invocations
|
|
449
|
+
return new ExpensiveService();
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// 4. Reduce package size
|
|
455
|
+
// .csproj - exclude unnecessary dependencies
|
|
456
|
+
<PropertyGroup>
|
|
457
|
+
<PublishTrimmed>true</PublishTrimmed>
|
|
458
|
+
<TrimMode>partial</TrimMode>
|
|
459
|
+
</PropertyGroup>
|
|
460
|
+
|
|
461
|
+
// 5. Run from package deployment
|
|
462
|
+
// Azure CLI
|
|
463
|
+
// az functionapp deployment source config-zip \
|
|
464
|
+
// --resource-group myResourceGroup \
|
|
465
|
+
// --name myFunctionApp \
|
|
466
|
+
// --src myapp.zip \
|
|
467
|
+
// --build-remote true
|
|
468
|
+
|
|
469
|
+
### Notes
|
|
470
|
+
|
|
471
|
+
- Cold starts improved ~53% across all regions/languages
|
|
472
|
+
- Premium Plan provides pre-warmed instances
|
|
473
|
+
- Warmup trigger initializes before traffic
|
|
474
|
+
- Package deployment can reduce cold start
|
|
475
|
+
|
|
476
|
+
### Queue Trigger with Error Handling
|
|
477
|
+
|
|
478
|
+
Reliable message processing with poison queue
|
|
479
|
+
|
|
480
|
+
**When to use**: Processing messages from Azure Storage Queue
|
|
481
|
+
|
|
482
|
+
### Template
|
|
483
|
+
|
|
484
|
+
// C# Isolated Worker - Queue Trigger
|
|
485
|
+
using Microsoft.Azure.Functions.Worker;
|
|
486
|
+
|
|
487
|
+
public class QueueProcessor
|
|
488
|
+
{
|
|
489
|
+
private readonly ILogger<QueueProcessor> _logger;
|
|
490
|
+
private readonly IMyService _service;
|
|
491
|
+
|
|
492
|
+
public QueueProcessor(ILogger<QueueProcessor> logger, IMyService service)
|
|
493
|
+
{
|
|
494
|
+
_logger = logger;
|
|
495
|
+
_service = service;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
[Function("ProcessQueueMessage")]
|
|
499
|
+
public async Task Run(
|
|
500
|
+
[QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")]
|
|
501
|
+
QueueMessage message)
|
|
502
|
+
{
|
|
503
|
+
_logger.LogInformation("Processing message: {Id}", message.MessageId);
|
|
504
|
+
|
|
505
|
+
try
|
|
506
|
+
{
|
|
507
|
+
var payload = JsonSerializer.Deserialize<MyPayload>(message.Body);
|
|
508
|
+
await _service.ProcessAsync(payload);
|
|
509
|
+
|
|
510
|
+
_logger.LogInformation("Message processed successfully: {Id}", message.MessageId);
|
|
511
|
+
}
|
|
512
|
+
catch (Exception ex)
|
|
513
|
+
{
|
|
514
|
+
_logger.LogError(ex, "Error processing message: {Id}", message.MessageId);
|
|
515
|
+
|
|
516
|
+
// Message will be retried up to maxDequeueCount (default 5)
|
|
517
|
+
// Then moved to poison queue: myqueue-items-poison
|
|
518
|
+
throw;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Optional: Monitor poison queue
|
|
523
|
+
[Function("ProcessPoisonQueue")]
|
|
524
|
+
public async Task ProcessPoison(
|
|
525
|
+
[QueueTrigger("myqueue-items-poison", Connection = "AzureWebJobsStorage")]
|
|
526
|
+
QueueMessage message)
|
|
527
|
+
{
|
|
528
|
+
_logger.LogWarning("Processing poison message: {Id}", message.MessageId);
|
|
529
|
+
|
|
530
|
+
// Log to monitoring, alert, or store for manual review
|
|
531
|
+
await _service.HandlePoisonMessageAsync(message);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// host.json - Queue configuration
|
|
536
|
+
// {
|
|
537
|
+
// "version": "2.0",
|
|
538
|
+
// "extensions": {
|
|
539
|
+
// "queues": {
|
|
540
|
+
// "maxPollingInterval": "00:00:02",
|
|
541
|
+
// "visibilityTimeout": "00:00:30",
|
|
542
|
+
// "batchSize": 16,
|
|
543
|
+
// "maxDequeueCount": 5,
|
|
544
|
+
// "newBatchThreshold": 8
|
|
545
|
+
// }
|
|
546
|
+
// }
|
|
547
|
+
// }
|
|
548
|
+
|
|
549
|
+
### Notes
|
|
550
|
+
|
|
551
|
+
- Messages retried up to maxDequeueCount times
|
|
552
|
+
- Failed messages moved to poison queue
|
|
553
|
+
- Configure visibilityTimeout for processing time
|
|
554
|
+
- batchSize controls parallel processing
|
|
555
|
+
|
|
556
|
+
### HTTP Trigger with Long-Running Pattern
|
|
557
|
+
|
|
558
|
+
Handle work exceeding 230-second HTTP limit
|
|
559
|
+
|
|
560
|
+
**When to use**: HTTP request triggers long-running work
|
|
561
|
+
|
|
562
|
+
### Template
|
|
563
|
+
|
|
564
|
+
// Async HTTP pattern - return immediately, poll for status
|
|
565
|
+
[Function("StartLongRunning")]
|
|
566
|
+
public static async Task<HttpResponseData> StartLongRunning(
|
|
567
|
+
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
|
|
568
|
+
[DurableClient] DurableTaskClient client,
|
|
569
|
+
FunctionContext context)
|
|
570
|
+
{
|
|
571
|
+
var input = await req.ReadFromJsonAsync<WorkRequest>();
|
|
572
|
+
|
|
573
|
+
// Start orchestration (returns immediately)
|
|
574
|
+
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
|
|
575
|
+
"LongRunningOrchestrator", input);
|
|
576
|
+
|
|
577
|
+
// Return status URLs for polling
|
|
578
|
+
return client.CreateCheckStatusResponse(req, instanceId);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Response includes:
|
|
582
|
+
// {
|
|
583
|
+
// "id": "abc123",
|
|
584
|
+
// "statusQueryGetUri": "https://.../instances/abc123",
|
|
585
|
+
// "sendEventPostUri": "https://.../instances/abc123/raiseEvent/{eventName}",
|
|
586
|
+
// "terminatePostUri": "https://.../instances/abc123/terminate"
|
|
587
|
+
// }
|
|
588
|
+
|
|
589
|
+
// Alternative: Queue-based pattern without Durable Functions
|
|
590
|
+
[Function("StartWork")]
|
|
591
|
+
[QueueOutput("work-queue")]
|
|
592
|
+
public static async Task<WorkItem> StartWork(
|
|
593
|
+
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
|
|
594
|
+
FunctionContext context)
|
|
595
|
+
{
|
|
596
|
+
var input = await req.ReadFromJsonAsync<WorkRequest>();
|
|
597
|
+
var workId = Guid.NewGuid().ToString();
|
|
598
|
+
|
|
599
|
+
// Queue the work, return immediately
|
|
600
|
+
var workItem = new WorkItem
|
|
601
|
+
{
|
|
602
|
+
Id = workId,
|
|
603
|
+
Request = input
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
// Return work ID for status checking
|
|
607
|
+
var response = req.CreateResponse(HttpStatusCode.Accepted);
|
|
608
|
+
await response.WriteAsJsonAsync(new
|
|
609
|
+
{
|
|
610
|
+
workId = workId,
|
|
611
|
+
statusUrl = $"/api/status/{workId}"
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
return workItem;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
[Function("ProcessWork")]
|
|
618
|
+
public static async Task ProcessWork(
|
|
619
|
+
[QueueTrigger("work-queue")] WorkItem work,
|
|
620
|
+
FunctionContext context)
|
|
621
|
+
{
|
|
622
|
+
// Long-running processing here
|
|
623
|
+
// Update status in storage for polling
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
### Notes
|
|
627
|
+
|
|
628
|
+
- HTTP timeout is 230 seconds regardless of plan
|
|
629
|
+
- Use Durable Functions for async patterns
|
|
630
|
+
- Return immediately with status endpoint
|
|
631
|
+
- Client polls for completion
|
|
632
|
+
|
|
633
|
+
## Sharp Edges
|
|
634
|
+
|
|
635
|
+
### HTTP Timeout is 230 Seconds Regardless of Plan
|
|
636
|
+
|
|
637
|
+
Severity: HIGH
|
|
638
|
+
|
|
639
|
+
Situation: HTTP-triggered functions with long processing time
|
|
640
|
+
|
|
641
|
+
Symptoms:
|
|
642
|
+
504 Gateway Timeout after ~4 minutes.
|
|
643
|
+
Request terminates before function completes.
|
|
644
|
+
Client receives timeout even though function continues.
|
|
645
|
+
host.json timeout setting has no effect for HTTP.
|
|
646
|
+
|
|
647
|
+
Why this breaks:
|
|
648
|
+
The Azure Load Balancer has a hard-coded 230-second idle timeout for HTTP
|
|
649
|
+
requests. This applies regardless of your function app timeout setting.
|
|
650
|
+
|
|
651
|
+
Even if you set functionTimeout to 30 minutes in host.json, HTTP triggers
|
|
652
|
+
will timeout after 230 seconds from the client's perspective.
|
|
653
|
+
|
|
654
|
+
The function may continue running after timeout, but the client won't
|
|
655
|
+
receive the response.
|
|
656
|
+
|
|
657
|
+
Recommended fix:
|
|
658
|
+
|
|
659
|
+
## Use async pattern with Durable Functions
|
|
660
|
+
|
|
661
|
+
```csharp
|
|
662
|
+
[Function("StartLongProcess")]
|
|
663
|
+
public static async Task<HttpResponseData> Start(
|
|
664
|
+
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
|
|
665
|
+
[DurableClient] DurableTaskClient client)
|
|
666
|
+
{
|
|
667
|
+
var input = await req.ReadFromJsonAsync<WorkRequest>();
|
|
668
|
+
|
|
669
|
+
// Start orchestration, returns immediately
|
|
670
|
+
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
|
|
671
|
+
"LongRunningOrchestrator", input);
|
|
672
|
+
|
|
673
|
+
// Returns status URLs for polling
|
|
674
|
+
return client.CreateCheckStatusResponse(req, instanceId);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// Client polls statusQueryGetUri until complete
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
## Use queue-based async pattern
|
|
681
|
+
|
|
682
|
+
```csharp
|
|
683
|
+
[Function("StartWork")]
|
|
684
|
+
public static async Task<HttpResponseData> StartWork(
|
|
685
|
+
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
|
|
686
|
+
[QueueOutput("work-queue")] out WorkItem workItem)
|
|
687
|
+
{
|
|
688
|
+
var workId = Guid.NewGuid().ToString();
|
|
689
|
+
|
|
690
|
+
workItem = new WorkItem { Id = workId, /* ... */ };
|
|
691
|
+
|
|
692
|
+
var response = req.CreateResponse(HttpStatusCode.Accepted);
|
|
693
|
+
await response.WriteAsJsonAsync(new {
|
|
694
|
+
id = workId,
|
|
695
|
+
statusUrl = $"/api/status/{workId}"
|
|
696
|
+
});
|
|
697
|
+
return response;
|
|
698
|
+
}
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
## Use webhook callback pattern
|
|
702
|
+
|
|
703
|
+
```csharp
|
|
704
|
+
// Client provides callback URL
|
|
705
|
+
// Function queues work, returns 202 Accepted
|
|
706
|
+
// When done, POST result to callback URL
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### Socket Exhaustion from HttpClient Instantiation
|
|
710
|
+
|
|
711
|
+
Severity: HIGH
|
|
712
|
+
|
|
713
|
+
Situation: Creating HttpClient instances inside function code
|
|
714
|
+
|
|
715
|
+
Symptoms:
|
|
716
|
+
SocketException: "Unable to connect to remote server"
|
|
717
|
+
"An attempt was made to access a socket in a way forbidden"
|
|
718
|
+
Sporadic connection failures under load.
|
|
719
|
+
Works locally but fails in production.
|
|
720
|
+
|
|
721
|
+
Why this breaks:
|
|
722
|
+
Creating a new HttpClient for each request creates a new socket connection.
|
|
723
|
+
Sockets linger in TIME_WAIT state for 240 seconds after closing.
|
|
724
|
+
|
|
725
|
+
In a serverless environment with high throughput, you quickly exhaust
|
|
726
|
+
available sockets. This affects all network clients, not just HttpClient.
|
|
727
|
+
|
|
728
|
+
Azure Functions shares network resources among multiple customers,
|
|
729
|
+
making this even more critical.
|
|
730
|
+
|
|
731
|
+
Recommended fix:
|
|
732
|
+
|
|
733
|
+
## Use IHttpClientFactory (Recommended)
|
|
734
|
+
|
|
735
|
+
```csharp
|
|
736
|
+
// Program.cs
|
|
737
|
+
var host = new HostBuilder()
|
|
738
|
+
.ConfigureFunctionsWorkerDefaults()
|
|
739
|
+
.ConfigureServices(services =>
|
|
740
|
+
{
|
|
741
|
+
services.AddHttpClient<IMyApiClient, MyApiClient>(client =>
|
|
742
|
+
{
|
|
743
|
+
client.BaseAddress = new Uri("https://api.example.com");
|
|
744
|
+
client.Timeout = TimeSpan.FromSeconds(30);
|
|
745
|
+
});
|
|
746
|
+
})
|
|
747
|
+
.Build();
|
|
748
|
+
|
|
749
|
+
// MyApiClient.cs
|
|
750
|
+
public class MyApiClient : IMyApiClient
|
|
751
|
+
{
|
|
752
|
+
private readonly HttpClient _client;
|
|
26
753
|
|
|
27
|
-
|
|
754
|
+
public MyApiClient(HttpClient client)
|
|
755
|
+
{
|
|
756
|
+
_client = client; // Injected, managed by factory
|
|
757
|
+
}
|
|
28
758
|
|
|
29
|
-
|
|
759
|
+
public async Task<string> GetDataAsync()
|
|
760
|
+
{
|
|
761
|
+
return await _client.GetStringAsync("/data");
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
```
|
|
30
765
|
|
|
31
|
-
|
|
766
|
+
## Use static client (Alternative)
|
|
32
767
|
|
|
33
|
-
|
|
768
|
+
```csharp
|
|
769
|
+
public static class MyFunction
|
|
770
|
+
{
|
|
771
|
+
// Static HttpClient, reused across invocations
|
|
772
|
+
private static readonly HttpClient _httpClient = new HttpClient
|
|
773
|
+
{
|
|
774
|
+
Timeout = TimeSpan.FromSeconds(30)
|
|
775
|
+
};
|
|
34
776
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
777
|
+
[Function("MyFunction")]
|
|
778
|
+
public static async Task Run(...)
|
|
779
|
+
{
|
|
780
|
+
var result = await _httpClient.GetAsync("...");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
## Same pattern for Azure SDK clients
|
|
786
|
+
|
|
787
|
+
```csharp
|
|
788
|
+
// Also applies to:
|
|
789
|
+
// - BlobServiceClient
|
|
790
|
+
// - CosmosClient
|
|
791
|
+
// - ServiceBusClient
|
|
792
|
+
// Use DI or static instances
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
### Blocking Async Calls Cause Thread Starvation
|
|
796
|
+
|
|
797
|
+
Severity: HIGH
|
|
798
|
+
|
|
799
|
+
Situation: Using .Result, .Wait(), or Thread.Sleep in async code
|
|
800
|
+
|
|
801
|
+
Symptoms:
|
|
802
|
+
Deadlocks under load.
|
|
803
|
+
Requests hang indefinitely.
|
|
804
|
+
"A task was canceled" exceptions.
|
|
805
|
+
Works with low concurrency, fails with high.
|
|
806
|
+
|
|
807
|
+
Why this breaks:
|
|
808
|
+
Azure Functions thread pool is limited. Blocking calls (.Result, .Wait())
|
|
809
|
+
hold a thread hostage while waiting, preventing other work.
|
|
810
|
+
|
|
811
|
+
Thread.Sleep blocks a thread that could be handling other requests.
|
|
812
|
+
|
|
813
|
+
With multiple concurrent executions, you quickly run out of threads,
|
|
814
|
+
causing deadlocks and timeouts.
|
|
815
|
+
|
|
816
|
+
Recommended fix:
|
|
817
|
+
|
|
818
|
+
## Always use async/await
|
|
819
|
+
|
|
820
|
+
```csharp
|
|
821
|
+
// BAD - blocks thread
|
|
822
|
+
var result = httpClient.GetAsync(url).Result;
|
|
823
|
+
someTask.Wait();
|
|
824
|
+
Thread.Sleep(5000);
|
|
825
|
+
|
|
826
|
+
// GOOD - yields thread
|
|
827
|
+
var result = await httpClient.GetAsync(url);
|
|
828
|
+
await someTask;
|
|
829
|
+
await Task.Delay(5000);
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
## Fix synchronous method calls
|
|
833
|
+
|
|
834
|
+
```csharp
|
|
835
|
+
// BAD - sync over async
|
|
836
|
+
public void ProcessData()
|
|
837
|
+
{
|
|
838
|
+
var data = GetDataAsync().Result; // Blocks!
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// GOOD - async all the way
|
|
842
|
+
public async Task ProcessDataAsync()
|
|
843
|
+
{
|
|
844
|
+
var data = await GetDataAsync();
|
|
845
|
+
}
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
## Configure async in console/startup
|
|
849
|
+
|
|
850
|
+
```csharp
|
|
851
|
+
// If you must call async from sync context
|
|
852
|
+
public static void Main(string[] args)
|
|
853
|
+
{
|
|
854
|
+
// Use GetAwaiter().GetResult() at entry point only
|
|
855
|
+
MainAsync(args).GetAwaiter().GetResult();
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
private static async Task MainAsync(string[] args)
|
|
859
|
+
{
|
|
860
|
+
// Async code here
|
|
861
|
+
}
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
### Consumption Plan 10-Minute Timeout Limit
|
|
865
|
+
|
|
866
|
+
Severity: MEDIUM
|
|
867
|
+
|
|
868
|
+
Situation: Running long processes on Consumption plan
|
|
869
|
+
|
|
870
|
+
Symptoms:
|
|
871
|
+
Function terminates after 10 minutes.
|
|
872
|
+
"Function timed out" in logs.
|
|
873
|
+
Incomplete processing with no error caught.
|
|
874
|
+
Works in development (with longer timeout) but fails in production.
|
|
875
|
+
|
|
876
|
+
Why this breaks:
|
|
877
|
+
Consumption plan has a hard limit of 10 minutes execution time.
|
|
878
|
+
Default is 5 minutes if not configured.
|
|
879
|
+
|
|
880
|
+
This cannot be increased beyond 10 minutes on Consumption plan.
|
|
881
|
+
Long-running work requires Premium plan or different architecture.
|
|
882
|
+
|
|
883
|
+
Recommended fix:
|
|
884
|
+
|
|
885
|
+
## Configure maximum timeout (Consumption)
|
|
886
|
+
|
|
887
|
+
```json
|
|
888
|
+
// host.json
|
|
889
|
+
{
|
|
890
|
+
"version": "2.0",
|
|
891
|
+
"functionTimeout": "00:10:00" // Max for Consumption
|
|
892
|
+
}
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
## Upgrade to Premium plan for longer timeouts
|
|
896
|
+
|
|
897
|
+
```json
|
|
898
|
+
// Premium plan - 30 min default, unbounded available
|
|
899
|
+
{
|
|
900
|
+
"version": "2.0",
|
|
901
|
+
"functionTimeout": "00:30:00" // Or remove for unbounded
|
|
902
|
+
}
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
## Use Durable Functions for long workflows
|
|
906
|
+
|
|
907
|
+
```csharp
|
|
908
|
+
[Function("LongWorkflowOrchestrator")]
|
|
909
|
+
public static async Task<string> RunOrchestrator(
|
|
910
|
+
[OrchestrationTrigger] TaskOrchestrationContext context)
|
|
911
|
+
{
|
|
912
|
+
// Each activity has its own timeout
|
|
913
|
+
// Workflow can run for days
|
|
914
|
+
await context.CallActivityAsync("Step1", input);
|
|
915
|
+
await context.CallActivityAsync("Step2", input);
|
|
916
|
+
await context.CallActivityAsync("Step3", input);
|
|
917
|
+
return "Complete";
|
|
918
|
+
}
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
## Break work into smaller chunks
|
|
922
|
+
|
|
923
|
+
```csharp
|
|
924
|
+
// Queue-based chunking
|
|
925
|
+
[Function("ProcessChunk")]
|
|
926
|
+
[QueueOutput("work-queue")]
|
|
927
|
+
public static IEnumerable<WorkChunk> ProcessChunk(
|
|
928
|
+
[QueueTrigger("work-queue")] WorkChunk chunk)
|
|
929
|
+
{
|
|
930
|
+
var results = Process(chunk);
|
|
931
|
+
|
|
932
|
+
// Queue next chunks if more work
|
|
933
|
+
if (chunk.HasMore)
|
|
934
|
+
{
|
|
935
|
+
yield return chunk.Next();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
### .NET In-Process Model Deprecated November 2026
|
|
941
|
+
|
|
942
|
+
Severity: HIGH
|
|
943
|
+
|
|
944
|
+
Situation: Creating new .NET functions or maintaining existing
|
|
945
|
+
|
|
946
|
+
Symptoms:
|
|
947
|
+
Using in-process model in new projects.
|
|
948
|
+
Dependency conflicts with host runtime.
|
|
949
|
+
Cannot use latest .NET versions.
|
|
950
|
+
Future migration burden.
|
|
951
|
+
|
|
952
|
+
Why this breaks:
|
|
953
|
+
The in-process model runs your code in the same process as the
|
|
954
|
+
Azure Functions host. This causes:
|
|
955
|
+
- Assembly version conflicts
|
|
956
|
+
- Limited to LTS .NET versions
|
|
957
|
+
- No access to latest .NET features
|
|
958
|
+
- Tighter coupling with host runtime
|
|
959
|
+
|
|
960
|
+
Support ends November 10, 2026. After this date, in-process apps
|
|
961
|
+
may stop working or receive no security updates.
|
|
962
|
+
|
|
963
|
+
Recommended fix:
|
|
964
|
+
|
|
965
|
+
## Use isolated worker for new projects
|
|
966
|
+
|
|
967
|
+
```bash
|
|
968
|
+
# Create new isolated worker project
|
|
969
|
+
func init MyFunctionApp --worker-runtime dotnet-isolated
|
|
970
|
+
|
|
971
|
+
# Or with .NET 8
|
|
972
|
+
dotnet new func --name MyFunctionApp --framework net8.0
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
## Migrate existing in-process to isolated
|
|
976
|
+
|
|
977
|
+
```csharp
|
|
978
|
+
// OLD - In-process (FunctionName attribute)
|
|
979
|
+
public class InProcessFunction
|
|
980
|
+
{
|
|
981
|
+
[FunctionName("MyFunction")]
|
|
982
|
+
public async Task<IActionResult> Run(
|
|
983
|
+
[HttpTrigger] HttpRequest req,
|
|
984
|
+
ILogger log)
|
|
985
|
+
{
|
|
986
|
+
log.LogInformation("Processing");
|
|
987
|
+
return new OkResult();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// NEW - Isolated worker (Function attribute)
|
|
992
|
+
public class IsolatedFunction
|
|
993
|
+
{
|
|
994
|
+
private readonly ILogger<IsolatedFunction> _logger;
|
|
995
|
+
|
|
996
|
+
public IsolatedFunction(ILogger<IsolatedFunction> logger)
|
|
997
|
+
{
|
|
998
|
+
_logger = logger;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
[Function("MyFunction")]
|
|
1002
|
+
public async Task<HttpResponseData> Run(
|
|
1003
|
+
[HttpTrigger(AuthorizationLevel.Function, "get")]
|
|
1004
|
+
HttpRequestData req)
|
|
1005
|
+
{
|
|
1006
|
+
_logger.LogInformation("Processing");
|
|
1007
|
+
return req.CreateResponse(HttpStatusCode.OK);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
## Key migration changes
|
|
1013
|
+
- FunctionName → Function attribute
|
|
1014
|
+
- HttpRequest → HttpRequestData
|
|
1015
|
+
- IActionResult → HttpResponseData
|
|
1016
|
+
- ILogger injection → constructor injection
|
|
1017
|
+
- Add Program.cs with HostBuilder
|
|
1018
|
+
|
|
1019
|
+
### ILogger Not Outputting to Console or AppInsights
|
|
1020
|
+
|
|
1021
|
+
Severity: MEDIUM
|
|
1022
|
+
|
|
1023
|
+
Situation: Using dependency-injected ILogger in isolated worker
|
|
1024
|
+
|
|
1025
|
+
Symptoms:
|
|
1026
|
+
Logs not appearing in local console.
|
|
1027
|
+
Logs not appearing in Application Insights.
|
|
1028
|
+
Logs work with context.GetLogger() but not injected ILogger.
|
|
1029
|
+
Must pass logger through all method calls.
|
|
1030
|
+
|
|
1031
|
+
Why this breaks:
|
|
1032
|
+
In isolated worker model, the dependency-injected ILogger may not
|
|
1033
|
+
be properly connected to the Azure Functions logging pipeline.
|
|
1034
|
+
|
|
1035
|
+
Local development especially affected - logs may go nowhere.
|
|
1036
|
+
Application Insights requires explicit configuration.
|
|
1037
|
+
|
|
1038
|
+
The ILogger from FunctionContext works differently than
|
|
1039
|
+
the injected ILogger<T>.
|
|
1040
|
+
|
|
1041
|
+
Recommended fix:
|
|
1042
|
+
|
|
1043
|
+
## Configure Application Insights properly
|
|
1044
|
+
|
|
1045
|
+
```csharp
|
|
1046
|
+
// Program.cs
|
|
1047
|
+
var host = new HostBuilder()
|
|
1048
|
+
.ConfigureFunctionsWorkerDefaults()
|
|
1049
|
+
.ConfigureServices(services =>
|
|
1050
|
+
{
|
|
1051
|
+
// Add App Insights telemetry
|
|
1052
|
+
services.AddApplicationInsightsTelemetryWorkerService();
|
|
1053
|
+
services.ConfigureFunctionsApplicationInsights();
|
|
1054
|
+
})
|
|
1055
|
+
.Build();
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
## Configure logging levels
|
|
1059
|
+
|
|
1060
|
+
```json
|
|
1061
|
+
// host.json
|
|
1062
|
+
{
|
|
1063
|
+
"version": "2.0",
|
|
1064
|
+
"logging": {
|
|
1065
|
+
"applicationInsights": {
|
|
1066
|
+
"samplingSettings": {
|
|
1067
|
+
"isEnabled": true,
|
|
1068
|
+
"excludedTypes": "Request"
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
"logLevel": {
|
|
1072
|
+
"default": "Information",
|
|
1073
|
+
"Host.Results": "Error",
|
|
1074
|
+
"Function": "Information",
|
|
1075
|
+
"Host.Aggregator": "Trace"
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
## Use context.GetLogger for reliability
|
|
1082
|
+
|
|
1083
|
+
```csharp
|
|
1084
|
+
[Function("MyFunction")]
|
|
1085
|
+
public async Task Run(
|
|
1086
|
+
[HttpTrigger] HttpRequestData req,
|
|
1087
|
+
FunctionContext context)
|
|
1088
|
+
{
|
|
1089
|
+
// This logger always works
|
|
1090
|
+
var logger = context.GetLogger<MyFunction>();
|
|
1091
|
+
logger.LogInformation("Processing request");
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
## Local development - check local.settings.json
|
|
1096
|
+
|
|
1097
|
+
```json
|
|
1098
|
+
{
|
|
1099
|
+
"IsEncrypted": false,
|
|
1100
|
+
"Values": {
|
|
1101
|
+
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
|
|
1102
|
+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
|
|
1103
|
+
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=..."
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
### Missing Extension Packages Cause Silent Failures
|
|
1109
|
+
|
|
1110
|
+
Severity: MEDIUM
|
|
1111
|
+
|
|
1112
|
+
Situation: Using triggers/bindings without installing extensions
|
|
1113
|
+
|
|
1114
|
+
Symptoms:
|
|
1115
|
+
Function not triggering on events.
|
|
1116
|
+
"No job functions found" warning.
|
|
1117
|
+
Bindings not working despite correct configuration.
|
|
1118
|
+
Works after adding extension package.
|
|
1119
|
+
|
|
1120
|
+
Why this breaks:
|
|
1121
|
+
Azure Functions v2+ uses extension bundles for triggers and bindings.
|
|
1122
|
+
If extensions aren't properly configured or packages aren't installed,
|
|
1123
|
+
the function host can't recognize the bindings.
|
|
1124
|
+
|
|
1125
|
+
In isolated worker, you need explicit NuGet packages.
|
|
1126
|
+
In in-process, you need Microsoft.Azure.WebJobs.Extensions.*.
|
|
1127
|
+
|
|
1128
|
+
Recommended fix:
|
|
1129
|
+
|
|
1130
|
+
## Check extension bundle (most common)
|
|
1131
|
+
|
|
1132
|
+
```json
|
|
1133
|
+
// host.json - Extension bundles handle most cases
|
|
1134
|
+
{
|
|
1135
|
+
"version": "2.0",
|
|
1136
|
+
"extensionBundle": {
|
|
1137
|
+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
|
|
1138
|
+
"version": "[4.*, 5.0.0)"
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
## Install explicit packages for isolated worker
|
|
1144
|
+
|
|
1145
|
+
```xml
|
|
1146
|
+
<!-- .csproj - Isolated worker packages -->
|
|
1147
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
|
|
1148
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.0" />
|
|
1149
|
+
|
|
1150
|
+
<!-- Storage triggers/bindings -->
|
|
1151
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
|
|
1152
|
+
|
|
1153
|
+
<!-- Service Bus -->
|
|
1154
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.14.0" />
|
|
1155
|
+
|
|
1156
|
+
<!-- Cosmos DB -->
|
|
1157
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.6.0" />
|
|
1158
|
+
|
|
1159
|
+
<!-- Durable Functions -->
|
|
1160
|
+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.0" />
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
## Verify function registration
|
|
1164
|
+
|
|
1165
|
+
```bash
|
|
1166
|
+
# Check registered functions
|
|
1167
|
+
func host start --verbose
|
|
1168
|
+
|
|
1169
|
+
# Look for:
|
|
1170
|
+
# "Found the following functions:"
|
|
1171
|
+
# If empty, check extensions and attributes
|
|
1172
|
+
```
|
|
1173
|
+
|
|
1174
|
+
### Premium Plan Still Has Cold Start on New Instances
|
|
1175
|
+
|
|
1176
|
+
Severity: MEDIUM
|
|
1177
|
+
|
|
1178
|
+
Situation: Using Premium plan expecting zero cold start
|
|
1179
|
+
|
|
1180
|
+
Symptoms:
|
|
1181
|
+
Still experiencing cold starts despite Premium plan.
|
|
1182
|
+
First request to new instance is slow.
|
|
1183
|
+
Latency spikes during scale-out events.
|
|
1184
|
+
Pre-warmed instances not being used.
|
|
1185
|
+
|
|
1186
|
+
Why this breaks:
|
|
1187
|
+
Premium plan provides pre-warmed instances, but:
|
|
1188
|
+
- Only one pre-warmed instance by default
|
|
1189
|
+
- Rapid scale-out still creates cold instances
|
|
1190
|
+
- Pre-warmed instances still run YOUR code initialization
|
|
1191
|
+
- Warmup trigger runs, but your code may still be slow
|
|
1192
|
+
|
|
1193
|
+
Pre-warmed means the runtime is ready, not your application.
|
|
1194
|
+
|
|
1195
|
+
Recommended fix:
|
|
1196
|
+
|
|
1197
|
+
## Add warmup trigger to initialize your code
|
|
1198
|
+
|
|
1199
|
+
```csharp
|
|
1200
|
+
[Function("Warmup")]
|
|
1201
|
+
public void Warmup(
|
|
1202
|
+
[WarmupTrigger] object warmupContext,
|
|
1203
|
+
FunctionContext context)
|
|
1204
|
+
{
|
|
1205
|
+
var logger = context.GetLogger("Warmup");
|
|
1206
|
+
logger.LogInformation("Warmup trigger fired");
|
|
1207
|
+
|
|
1208
|
+
// Initialize expensive resources
|
|
1209
|
+
_cosmosClient.GetContainer("db", "container");
|
|
1210
|
+
_httpClient.GetAsync("https://api.example.com/health").Wait();
|
|
1211
|
+
}
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
## Configure pre-warmed instance count
|
|
1215
|
+
|
|
1216
|
+
```bash
|
|
1217
|
+
# Increase pre-warmed instances (costs more)
|
|
1218
|
+
az functionapp config set \
|
|
1219
|
+
--name <app-name> \
|
|
1220
|
+
--resource-group <rg> \
|
|
1221
|
+
--prewarmed-instance-count 3
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
## Optimize application initialization
|
|
1225
|
+
|
|
1226
|
+
```csharp
|
|
1227
|
+
// Lazy initialize heavy resources
|
|
1228
|
+
private static readonly Lazy<ExpensiveClient> _client =
|
|
1229
|
+
new Lazy<ExpensiveClient>(() => new ExpensiveClient());
|
|
1230
|
+
|
|
1231
|
+
// Connection pooling
|
|
1232
|
+
services.AddDbContext<MyDbContext>(options =>
|
|
1233
|
+
options.UseSqlServer(connectionString, sql =>
|
|
1234
|
+
sql.MinPoolSize(5)));
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
## Use always-ready instances (most expensive)
|
|
1238
|
+
|
|
1239
|
+
```bash
|
|
1240
|
+
# Instances always running, no cold start
|
|
1241
|
+
az functionapp config set \
|
|
1242
|
+
--name <app-name> \
|
|
1243
|
+
--resource-group <rg> \
|
|
1244
|
+
--minimum-elastic-instance-count 2
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
## Validation Checks
|
|
1248
|
+
|
|
1249
|
+
### Hardcoded Connection String
|
|
1250
|
+
|
|
1251
|
+
Severity: ERROR
|
|
1252
|
+
|
|
1253
|
+
Connection strings must never be hardcoded
|
|
1254
|
+
|
|
1255
|
+
Message: Hardcoded connection string. Use Key Vault or App Settings.
|
|
1256
|
+
|
|
1257
|
+
### Hardcoded API Key in Code
|
|
1258
|
+
|
|
1259
|
+
Severity: ERROR
|
|
1260
|
+
|
|
1261
|
+
API keys should use Key Vault or App Settings
|
|
1262
|
+
|
|
1263
|
+
Message: Hardcoded API key. Use Key Vault or environment variables.
|
|
1264
|
+
|
|
1265
|
+
### Anonymous Authorization Level in Production
|
|
1266
|
+
|
|
1267
|
+
Severity: WARNING
|
|
1268
|
+
|
|
1269
|
+
Anonymous endpoints should be protected by other means
|
|
1270
|
+
|
|
1271
|
+
Message: Anonymous authorization. Ensure protected by API Management or other auth.
|
|
1272
|
+
|
|
1273
|
+
### Blocking .Result Call
|
|
1274
|
+
|
|
1275
|
+
Severity: ERROR
|
|
1276
|
+
|
|
1277
|
+
Using .Result blocks threads and causes deadlocks
|
|
1278
|
+
|
|
1279
|
+
Message: Blocking .Result call. Use await instead.
|
|
1280
|
+
|
|
1281
|
+
### Blocking .Wait() Call
|
|
1282
|
+
|
|
1283
|
+
Severity: ERROR
|
|
1284
|
+
|
|
1285
|
+
Using .Wait() blocks threads
|
|
1286
|
+
|
|
1287
|
+
Message: Blocking .Wait() call. Use await instead.
|
|
1288
|
+
|
|
1289
|
+
### Thread.Sleep Usage
|
|
1290
|
+
|
|
1291
|
+
Severity: ERROR
|
|
1292
|
+
|
|
1293
|
+
Thread.Sleep blocks threads
|
|
1294
|
+
|
|
1295
|
+
Message: Thread.Sleep blocks threads. Use await Task.Delay() instead.
|
|
1296
|
+
|
|
1297
|
+
### New HttpClient Instance
|
|
1298
|
+
|
|
1299
|
+
Severity: WARNING
|
|
1300
|
+
|
|
1301
|
+
Creating HttpClient per request causes socket exhaustion
|
|
1302
|
+
|
|
1303
|
+
Message: New HttpClient per request. Use IHttpClientFactory or static client.
|
|
1304
|
+
|
|
1305
|
+
### HttpClient in Using Statement
|
|
1306
|
+
|
|
1307
|
+
Severity: WARNING
|
|
1308
|
+
|
|
1309
|
+
Disposing HttpClient causes socket exhaustion
|
|
1310
|
+
|
|
1311
|
+
Message: HttpClient in using statement. Use IHttpClientFactory for proper lifecycle.
|
|
1312
|
+
|
|
1313
|
+
### In-Process FunctionName Attribute
|
|
1314
|
+
|
|
1315
|
+
Severity: INFO
|
|
1316
|
+
|
|
1317
|
+
In-process model deprecated November 2026
|
|
1318
|
+
|
|
1319
|
+
Message: In-process FunctionName attribute. Consider migrating to isolated worker.
|
|
1320
|
+
|
|
1321
|
+
### Missing Function Attribute
|
|
1322
|
+
|
|
1323
|
+
Severity: WARNING
|
|
1324
|
+
|
|
1325
|
+
Isolated worker requires [Function] attribute
|
|
1326
|
+
|
|
1327
|
+
Message: HttpTrigger without [Function] attribute (isolated worker requires it).
|
|
1328
|
+
|
|
1329
|
+
## Collaboration
|
|
1330
|
+
|
|
1331
|
+
### Delegation Triggers
|
|
1332
|
+
|
|
1333
|
+
- user needs AWS serverless -> aws-serverless (Lambda, API Gateway, SAM)
|
|
1334
|
+
- user needs GCP serverless -> gcp-cloud-run (Cloud Run, Cloud Functions)
|
|
1335
|
+
- user needs container-based deployment -> gcp-cloud-run (Azure Container Apps or Cloud Run)
|
|
1336
|
+
- user needs database design -> postgres-wizard (Azure SQL, Cosmos DB data modeling)
|
|
1337
|
+
- user needs authentication -> auth-specialist (Azure AD, Easy Auth, managed identity)
|
|
1338
|
+
- user needs complex orchestration -> workflow-automation (Logic Apps, Power Automate)
|
|
45
1339
|
|
|
46
1340
|
## When to Use
|
|
47
|
-
|
|
1341
|
+
|
|
1342
|
+
- User mentions or implies: azure function
|
|
1343
|
+
- User mentions or implies: azure functions
|
|
1344
|
+
- User mentions or implies: durable functions
|
|
1345
|
+
- User mentions or implies: azure serverless
|
|
1346
|
+
- User mentions or implies: function app
|