@deftai/directive-content 0.55.0
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/.agents/skills/deft/SKILL.md +6 -0
- package/.agents/skills/deft-directive-article-review/SKILL.md +11 -0
- package/.agents/skills/deft-directive-build/SKILL.md +10 -0
- package/.agents/skills/deft-directive-cost/SKILL.md +12 -0
- package/.agents/skills/deft-directive-debug/SKILL.md +13 -0
- package/.agents/skills/deft-directive-gh-arch/SKILL.md +11 -0
- package/.agents/skills/deft-directive-gh-slice/SKILL.md +10 -0
- package/.agents/skills/deft-directive-glossary/SKILL.md +10 -0
- package/.agents/skills/deft-directive-interview/SKILL.md +9 -0
- package/.agents/skills/deft-directive-pre-pr/SKILL.md +9 -0
- package/.agents/skills/deft-directive-refinement/SKILL.md +10 -0
- package/.agents/skills/deft-directive-release/SKILL.md +12 -0
- package/.agents/skills/deft-directive-review-cycle/SKILL.md +10 -0
- package/.agents/skills/deft-directive-setup/SKILL.md +10 -0
- package/.agents/skills/deft-directive-swarm/SKILL.md +10 -0
- package/.agents/skills/deft-directive-sync/SKILL.md +9 -0
- package/.agents/skills/deft-directive-triage/SKILL.md +9 -0
- package/.agents/skills/deft-directive-write-skill/SKILL.md +9 -0
- package/LICENSE.md +22 -0
- package/QUICK-START.md +167 -0
- package/UPGRADING.md +517 -0
- package/coding/build-output.md +28 -0
- package/coding/coding.md +235 -0
- package/coding/debugging.md +110 -0
- package/coding/holzmann.md +96 -0
- package/coding/hygiene.md +127 -0
- package/coding/security.md +158 -0
- package/coding/testing.md +162 -0
- package/coding/toolchain.md +44 -0
- package/commands.md +300 -0
- package/context/context.md +57 -0
- package/context/deterministic-split.md +67 -0
- package/context/examples.md +26 -0
- package/context/fractal-summaries.md +69 -0
- package/context/long-horizon.md +46 -0
- package/context/spec-deltas.md +177 -0
- package/context/tool-design.md +34 -0
- package/context/working-memory.md +62 -0
- package/contracts/boundary-maps.md +65 -0
- package/contracts/deterministic-questions.md +59 -0
- package/contracts/hierarchy.md +77 -0
- package/conventions/content-manifest.json +399 -0
- package/conventions/machine-generated-banner.md +130 -0
- package/conventions/references.md +120 -0
- package/conventions/rule-ownership.json +382 -0
- package/conventions/task-caching.md +43 -0
- package/conventions/vbrief-filenames.md +70 -0
- package/deployments/README.md +37 -0
- package/deployments/agentuity/README.md +138 -0
- package/deployments/agentuity/via-cli.md +380 -0
- package/deployments/agentuity/via-cloud.md +425 -0
- package/deployments/agentuity/via-github-actions.md +664 -0
- package/deployments/agentuity/via-gravity-network.md +606 -0
- package/deployments/agentuity/via-vpc.md +607 -0
- package/deployments/aws/README.md +38 -0
- package/deployments/aws/via-app-runner.md +612 -0
- package/deployments/aws/via-ecs-fargate.md +561 -0
- package/deployments/aws/via-elastic-beanstalk.md +628 -0
- package/deployments/aws/via-lambda.md +649 -0
- package/deployments/azure/README.md +37 -0
- package/deployments/azure/via-aks.md +390 -0
- package/deployments/azure/via-app-service.md +564 -0
- package/deployments/azure/via-container-apps.md +599 -0
- package/deployments/azure/via-functions.md +552 -0
- package/deployments/cloud-gov/README.md +63 -0
- package/deployments/cloud-gov/agents/compliance-docs.md +154 -0
- package/deployments/cloud-gov/agents.md +39 -0
- package/deployments/cloud-gov/cicd.md +64 -0
- package/deployments/cloud-gov/deployment.md +150 -0
- package/deployments/cloud-gov/logging.md +43 -0
- package/deployments/cloud-gov/manifest.md +121 -0
- package/deployments/cloud-gov/overview.md +58 -0
- package/deployments/cloud-gov/security.md +46 -0
- package/deployments/cloud-gov/services.md +72 -0
- package/deployments/cloud-gov/upstream/README.md +18 -0
- package/deployments/cloudflare/README.md +33 -0
- package/deployments/cloudflare/via-dashboard.md +83 -0
- package/deployments/cloudflare/via-git.md +90 -0
- package/deployments/cloudflare/via-github-actions.md +185 -0
- package/deployments/cloudflare/via-terraform.md +157 -0
- package/deployments/cloudflare/via-wrangler.md +165 -0
- package/deployments/fly-io/README.md +37 -0
- package/deployments/fly-io/via-dockerfile.md +648 -0
- package/deployments/fly-io/via-flyctl.md +653 -0
- package/deployments/fly-io/via-github-actions.md +695 -0
- package/deployments/fly-io/via-multi-region.md +598 -0
- package/deployments/google/README.md +34 -0
- package/deployments/google/via-app-engine.md +42 -0
- package/deployments/google/via-cloud-functions.md +23 -0
- package/deployments/google/via-cloud-run.md +330 -0
- package/deployments/google/via-gke.md +23 -0
- package/deployments/netlify/README.md +99 -0
- package/deployments/netlify/via-cli.md +17 -0
- package/deployments/netlify/via-functions.md +19 -0
- package/deployments/netlify/via-git.md +25 -0
- package/deployments/vercel/README.md +90 -0
- package/deployments/vercel/via-api.md +16 -0
- package/deployments/vercel/via-cli.md +17 -0
- package/deployments/vercel/via-git.md +24 -0
- package/docs/BROWNFIELD.md +179 -0
- package/docs/getting-started.md +137 -0
- package/docs/good-agents-md.md +137 -0
- package/events/README.md +89 -0
- package/events/event-record.schema.json +26 -0
- package/events/registry.json +166 -0
- package/events/registry.schema.json +71 -0
- package/glossary.md +145 -0
- package/incidents/README.md +81 -0
- package/incidents/_template.md +38 -0
- package/interfaces/cli.md +104 -0
- package/interfaces/rest.md +212 -0
- package/interfaces/tui.md +242 -0
- package/interfaces/web.md +123 -0
- package/languages/6502-DASM.md +132 -0
- package/languages/c.md +235 -0
- package/languages/commands.md +23 -0
- package/languages/cpp.md +132 -0
- package/languages/csharp.md +259 -0
- package/languages/dart.md +183 -0
- package/languages/delphi.md +218 -0
- package/languages/elixir.md +208 -0
- package/languages/go.md +78 -0
- package/languages/java.md +278 -0
- package/languages/javascript.md +163 -0
- package/languages/julia.md +175 -0
- package/languages/kotlin.md +193 -0
- package/languages/markdown.md +168 -0
- package/languages/mermaid.md +146 -0
- package/languages/officejs.md +392 -0
- package/languages/python.md +209 -0
- package/languages/r.md +163 -0
- package/languages/rust.md +216 -0
- package/languages/sql.md +216 -0
- package/languages/swift.md +153 -0
- package/languages/typescript.md +132 -0
- package/languages/vba.md +279 -0
- package/languages/vhdl.md +180 -0
- package/languages/visual-basic.md +151 -0
- package/languages/zig.md +196 -0
- package/meta/SOUL.md +27 -0
- package/meta/code-field.md +44 -0
- package/meta/morals.md +40 -0
- package/meta/philosophy.md +39 -0
- package/meta/project.md +49 -0
- package/meta/ralph.md +223 -0
- package/meta/security.md +80 -0
- package/meta/versioning.md +326 -0
- package/package.json +22 -0
- package/packs/lessons/lessons-pack-0.1.json +553 -0
- package/packs/patterns/patterns-pack-0.1.json +57 -0
- package/packs/rules/rules-pack-0.1.json +4767 -0
- package/packs/skills/skills-pack-0.1.json +262 -0
- package/packs/strategies/strategies-pack-0.1.json +167 -0
- package/packs/swarm-spec/swarm-spec-pack-0.1.json +17 -0
- package/patterns/executor-layer-credentials.md +227 -0
- package/patterns/llm-app.md +156 -0
- package/patterns/multi-agent.md +278 -0
- package/patterns/prompt-assembly-layer-ordering.md +154 -0
- package/patterns/role-as-overlay.md +179 -0
- package/platforms/2600.md +137 -0
- package/platforms/unity.md +329 -0
- package/references/composer-skill-porting.md +152 -0
- package/references/cost-models.md +163 -0
- package/references/ip-risk.md +246 -0
- package/references/plain-english-ux.md +275 -0
- package/resilience/context-pruning.md +67 -0
- package/resilience/continue-here.md +62 -0
- package/scm/changelog.md +276 -0
- package/scm/git.md +139 -0
- package/scm/github.md +265 -0
- package/secrets/.gitkeep +0 -0
- package/skills/deft-build/SKILL.md +20 -0
- package/skills/deft-directive-article-review/SKILL.md +156 -0
- package/skills/deft-directive-build/SKILL.md +302 -0
- package/skills/deft-directive-cost/SKILL.md +201 -0
- package/skills/deft-directive-debug/SKILL.md +140 -0
- package/skills/deft-directive-decompose/SKILL.md +96 -0
- package/skills/deft-directive-gh-arch/SKILL.md +160 -0
- package/skills/deft-directive-gh-slice/SKILL.md +199 -0
- package/skills/deft-directive-glossary/SKILL.md +118 -0
- package/skills/deft-directive-interview/SKILL.md +528 -0
- package/skills/deft-directive-pre-pr/SKILL.md +131 -0
- package/skills/deft-directive-probe/SKILL.md +127 -0
- package/skills/deft-directive-refinement/SKILL.md +403 -0
- package/skills/deft-directive-release/SKILL.md +266 -0
- package/skills/deft-directive-review-cycle/SKILL.md +401 -0
- package/skills/deft-directive-setup/SKILL.md +717 -0
- package/skills/deft-directive-swarm/SKILL.md +989 -0
- package/skills/deft-directive-sync/SKILL.md +288 -0
- package/skills/deft-directive-triage/SKILL.md +137 -0
- package/skills/deft-directive-write-skill/SKILL.md +169 -0
- package/skills/deft-interview/SKILL.md +16 -0
- package/skills/deft-pre-pr/SKILL.md +16 -0
- package/skills/deft-review-cycle/SKILL.md +16 -0
- package/skills/deft-roadmap-refresh/SKILL.md +16 -0
- package/skills/deft-setup/SKILL.md +20 -0
- package/skills/deft-swarm/SKILL.md +16 -0
- package/skills/deft-sync/SKILL.md +16 -0
- package/strategies/README.md +83 -0
- package/strategies/artifact-guards.md +85 -0
- package/strategies/bdd.md +115 -0
- package/strategies/brownfield.md +7 -0
- package/strategies/discuss.md +129 -0
- package/strategies/emit-hints.md +69 -0
- package/strategies/enterprise.md +193 -0
- package/strategies/interview.md +551 -0
- package/strategies/map.md +179 -0
- package/strategies/probe.md +151 -0
- package/strategies/rapid.md +155 -0
- package/strategies/research.md +155 -0
- package/strategies/roadmap.md +9 -0
- package/strategies/speckit.md +437 -0
- package/strategies/v0-20-contract.md +134 -0
- package/strategies/yolo.md +169 -0
- package/swarm/swarm.md +300 -0
- package/templates/COST-ESTIMATE.md +114 -0
- package/templates/PULL_REQUEST_TEMPLATE.md +35 -0
- package/templates/agent-prompt-preamble.md +409 -0
- package/templates/agents-entry.md +211 -0
- package/templates/agents-entry.placeholders.md +75 -0
- package/templates/embed.go +20 -0
- package/templates/embed_test.go +36 -0
- package/templates/make-spec-example.md +9 -0
- package/templates/make-spec.md +246 -0
- package/templates/project.md.template +52 -0
- package/templates/specification.md +1 -0
- package/templates/swarm-greptile-poller-prompt.md +556 -0
- package/templates/user.md.template +31 -0
- package/tools/RWLDL.md +80 -0
- package/tools/greptile.md +141 -0
- package/tools/installer.md +23 -0
- package/tools/taskfile-migration.md +32 -0
- package/tools/taskfile.md +185 -0
- package/tools/telemetry.md +285 -0
- package/vbrief/schemas/cache-meta.schema.json +137 -0
- package/vbrief/schemas/candidates.schema.json +130 -0
- package/vbrief/schemas/codebase-map.schema.json +213 -0
- package/vbrief/schemas/lessons-pack.schema.json +134 -0
- package/vbrief/schemas/patterns-pack.schema.json +84 -0
- package/vbrief/schemas/rules-pack.schema.json +105 -0
- package/vbrief/schemas/skills-pack.schema.json +94 -0
- package/vbrief/schemas/slices.schema.json +87 -0
- package/vbrief/schemas/strategies-pack.schema.json +89 -0
- package/vbrief/schemas/swarm-spec-pack.schema.json +84 -0
- package/vbrief/schemas/vbrief-core.schema.json +1022 -0
- package/vbrief/vbrief.md +684 -0
- package/verification/integration.md +76 -0
- package/verification/plan-checking.md +85 -0
- package/verification/uat.md +60 -0
- package/verification/verification.md +117 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
# Deploy via Azure Functions
|
|
2
|
+
|
|
3
|
+
Deploy serverless functions using Azure Functions. Event-driven compute that scales automatically with consumption-based pricing.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Azure Functions provides:
|
|
8
|
+
- **Serverless Compute**: No infrastructure management
|
|
9
|
+
- **Event-Driven**: Trigger from HTTP, timers, queues, and more
|
|
10
|
+
- **Multiple Languages**: C#, JavaScript, Python, Java, PowerShell
|
|
11
|
+
- **Durable Functions**: Stateful workflows
|
|
12
|
+
- **Flexible Hosting**: Consumption, Premium, and Dedicated plans
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- Azure account with subscription
|
|
17
|
+
- Azure Functions Core Tools installed
|
|
18
|
+
- Azure CLI installed
|
|
19
|
+
- Runtime installed (Node.js, Python, etc.)
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### 1. Install Azure Functions Core Tools
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# macOS
|
|
27
|
+
brew tap azure/functions
|
|
28
|
+
brew install azure-functions-core-tools@4
|
|
29
|
+
|
|
30
|
+
# Or via npm
|
|
31
|
+
npm install -g azure-functions-core-tools@4
|
|
32
|
+
|
|
33
|
+
# Verify
|
|
34
|
+
func --version
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Create Function App
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Create local project
|
|
41
|
+
func init myapp --python
|
|
42
|
+
|
|
43
|
+
cd myapp
|
|
44
|
+
|
|
45
|
+
# Create HTTP trigger function
|
|
46
|
+
func new --name HttpTrigger --template "HTTP trigger"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Test Locally
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Start local runtime
|
|
53
|
+
func start
|
|
54
|
+
|
|
55
|
+
# Test function
|
|
56
|
+
curl http://localhost:7071/api/HttpTrigger
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 4. Deploy to Azure
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Login
|
|
63
|
+
az login
|
|
64
|
+
|
|
65
|
+
# Create resource group
|
|
66
|
+
az group create --name myapp-rg --location eastus
|
|
67
|
+
|
|
68
|
+
# Create storage account (required)
|
|
69
|
+
az storage account create \
|
|
70
|
+
--name myappstorage \
|
|
71
|
+
--resource-group myapp-rg \
|
|
72
|
+
--location eastus \
|
|
73
|
+
--sku Standard_LRS
|
|
74
|
+
|
|
75
|
+
# Create Function App
|
|
76
|
+
az functionapp create \
|
|
77
|
+
--name myapp \
|
|
78
|
+
--resource-group myapp-rg \
|
|
79
|
+
--consumption-plan-location eastus \
|
|
80
|
+
--runtime python \
|
|
81
|
+
--runtime-version 3.11 \
|
|
82
|
+
--functions-version 4 \
|
|
83
|
+
--storage-account myappstorage
|
|
84
|
+
|
|
85
|
+
# Deploy
|
|
86
|
+
func azure functionapp publish myapp
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Language-Specific Examples
|
|
90
|
+
|
|
91
|
+
### Python Function
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
# function_app.py
|
|
95
|
+
import azure.functions as func
|
|
96
|
+
import logging
|
|
97
|
+
|
|
98
|
+
app = func.FunctionApp()
|
|
99
|
+
|
|
100
|
+
@app.function_name(name="HttpTrigger")
|
|
101
|
+
@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
|
|
102
|
+
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
|
|
103
|
+
logging.info('Python HTTP trigger function processed a request.')
|
|
104
|
+
|
|
105
|
+
name = req.params.get('name')
|
|
106
|
+
if not name:
|
|
107
|
+
try:
|
|
108
|
+
req_body = req.get_json()
|
|
109
|
+
name = req_body.get('name')
|
|
110
|
+
except ValueError:
|
|
111
|
+
pass
|
|
112
|
+
|
|
113
|
+
if name:
|
|
114
|
+
return func.HttpResponse(f"Hello, {name}!")
|
|
115
|
+
else:
|
|
116
|
+
return func.HttpResponse(
|
|
117
|
+
"Please pass a name on the query string or in the request body",
|
|
118
|
+
status_code=400
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
@app.function_name(name="TimerTrigger")
|
|
122
|
+
@app.schedule(schedule="0 */5 * * * *", arg_name="timer")
|
|
123
|
+
def timer_trigger(timer: func.TimerRequest) -> None:
|
|
124
|
+
logging.info('Timer trigger function ran')
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Node.js Function
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
// src/functions/httpTrigger.js
|
|
131
|
+
const { app } = require('@azure/functions');
|
|
132
|
+
|
|
133
|
+
app.http('httpTrigger', {
|
|
134
|
+
methods: ['GET', 'POST'],
|
|
135
|
+
authLevel: 'anonymous',
|
|
136
|
+
handler: async (request, context) => {
|
|
137
|
+
context.log('HTTP trigger function processed a request');
|
|
138
|
+
|
|
139
|
+
const name = request.query.get('name') || await request.text() || 'World';
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
status: 200,
|
|
143
|
+
body: `Hello, ${name}!`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Timer trigger
|
|
149
|
+
app.timer('timerTrigger', {
|
|
150
|
+
schedule: '0 */5 * * * *',
|
|
151
|
+
handler: (myTimer, context) => {
|
|
152
|
+
context.log('Timer trigger function ran');
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### C# Function
|
|
158
|
+
|
|
159
|
+
```csharp
|
|
160
|
+
// HttpTrigger.cs
|
|
161
|
+
using Microsoft.AspNetCore.Http;
|
|
162
|
+
using Microsoft.AspNetCore.Mvc;
|
|
163
|
+
using Microsoft.Azure.Functions.Worker;
|
|
164
|
+
using Microsoft.Extensions.Logging;
|
|
165
|
+
|
|
166
|
+
namespace MyApp
|
|
167
|
+
{
|
|
168
|
+
public class HttpTrigger
|
|
169
|
+
{
|
|
170
|
+
private readonly ILogger<HttpTrigger> _logger;
|
|
171
|
+
|
|
172
|
+
public HttpTrigger(ILogger<HttpTrigger> logger)
|
|
173
|
+
{
|
|
174
|
+
_logger = logger;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[Function("HttpTrigger")]
|
|
178
|
+
public IActionResult Run(
|
|
179
|
+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
|
|
180
|
+
{
|
|
181
|
+
_logger.LogInformation("C# HTTP trigger function processed a request");
|
|
182
|
+
|
|
183
|
+
string name = req.Query["name"];
|
|
184
|
+
|
|
185
|
+
return new OkObjectResult($"Hello, {name ?? "World"}!");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Triggers and Bindings
|
|
192
|
+
|
|
193
|
+
### HTTP Trigger
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
@app.route(route="api/users/{id}", methods=["GET"])
|
|
197
|
+
def get_user(req: func.HttpRequest) -> func.HttpResponse:
|
|
198
|
+
user_id = req.route_params.get('id')
|
|
199
|
+
return func.HttpResponse(f"User ID: {user_id}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Timer Trigger
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
# Runs every day at 2 AM
|
|
206
|
+
@app.schedule(schedule="0 0 2 * * *", arg_name="timer")
|
|
207
|
+
def daily_job(timer: func.TimerRequest) -> None:
|
|
208
|
+
logging.info('Daily job executed')
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Queue Trigger
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
@app.queue_trigger(
|
|
215
|
+
arg_name="msg",
|
|
216
|
+
queue_name="myqueue",
|
|
217
|
+
connection="AzureWebJobsStorage"
|
|
218
|
+
)
|
|
219
|
+
def queue_processor(msg: func.QueueMessage) -> None:
|
|
220
|
+
logging.info(f'Processing queue message: {msg.get_body().decode()}')
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Blob Trigger
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
@app.blob_trigger(
|
|
227
|
+
arg_name="blob",
|
|
228
|
+
path="container/{name}",
|
|
229
|
+
connection="AzureWebJobsStorage"
|
|
230
|
+
)
|
|
231
|
+
def blob_processor(blob: func.InputStream) -> None:
|
|
232
|
+
logging.info(f'Processing blob: {blob.name}, size: {blob.length} bytes')
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Event Hub Trigger
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
@app.event_hub_message_trigger(
|
|
239
|
+
arg_name="events",
|
|
240
|
+
event_hub_name="myhub",
|
|
241
|
+
connection="EventHubConnection"
|
|
242
|
+
)
|
|
243
|
+
def event_hub_processor(events: List[func.EventHubEvent]) -> None:
|
|
244
|
+
for event in events:
|
|
245
|
+
logging.info(f'Event: {event.get_body().decode()}')
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Cosmos DB Trigger
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
@app.cosmos_db_trigger(
|
|
252
|
+
arg_name="documents",
|
|
253
|
+
database_name="mydb",
|
|
254
|
+
collection_name="mycollection",
|
|
255
|
+
connection_string_setting="CosmosDBConnection",
|
|
256
|
+
lease_collection_name="leases",
|
|
257
|
+
create_lease_collection_if_not_exists=True
|
|
258
|
+
)
|
|
259
|
+
def cosmos_processor(documents: func.DocumentList) -> None:
|
|
260
|
+
for doc in documents:
|
|
261
|
+
logging.info(f'Document modified: {doc["id"]}')
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Configuration
|
|
265
|
+
|
|
266
|
+
### Application Settings
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Set environment variables
|
|
270
|
+
az functionapp config appsettings set \
|
|
271
|
+
--name myapp \
|
|
272
|
+
--resource-group myapp-rg \
|
|
273
|
+
--settings \
|
|
274
|
+
APP_ENV=production \
|
|
275
|
+
DATABASE_URL="@Microsoft.KeyVault(SecretUri=...)"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Connection Strings
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
az functionapp config connection-string set \
|
|
282
|
+
--name myapp \
|
|
283
|
+
--resource-group myapp-rg \
|
|
284
|
+
--connection-string-type SQLAzure \
|
|
285
|
+
--settings \
|
|
286
|
+
DefaultConnection="Server=..."
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Durable Functions
|
|
290
|
+
|
|
291
|
+
### Orchestrator Function
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
import azure.durable_functions as df
|
|
295
|
+
|
|
296
|
+
@app.orchestration_trigger(context_name="context")
|
|
297
|
+
def orchestrator(context: df.DurableOrchestrationContext):
|
|
298
|
+
# Chain activities
|
|
299
|
+
result1 = yield context.call_activity("Activity1", "input1")
|
|
300
|
+
result2 = yield context.call_activity("Activity2", result1)
|
|
301
|
+
result3 = yield context.call_activity("Activity3", result2)
|
|
302
|
+
|
|
303
|
+
return result3
|
|
304
|
+
|
|
305
|
+
@app.activity_trigger(input_name="input")
|
|
306
|
+
def activity1(input: str) -> str:
|
|
307
|
+
return f"Activity1: {input}"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Fan-out/Fan-in Pattern
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
@app.orchestration_trigger(context_name="context")
|
|
314
|
+
def fan_out_fan_in(context: df.DurableOrchestrationContext):
|
|
315
|
+
tasks = []
|
|
316
|
+
|
|
317
|
+
# Fan-out: start parallel activities
|
|
318
|
+
for i in range(10):
|
|
319
|
+
tasks.append(context.call_activity("ProcessItem", i))
|
|
320
|
+
|
|
321
|
+
# Fan-in: wait for all to complete
|
|
322
|
+
results = yield context.task_all(tasks)
|
|
323
|
+
|
|
324
|
+
total = sum(results)
|
|
325
|
+
return total
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Hosting Plans
|
|
329
|
+
|
|
330
|
+
### Consumption Plan (Default)
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
az functionapp create \
|
|
334
|
+
--name myapp \
|
|
335
|
+
--resource-group myapp-rg \
|
|
336
|
+
--consumption-plan-location eastus \
|
|
337
|
+
--runtime python \
|
|
338
|
+
--storage-account myappstorage
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Premium Plan
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
# Create Premium plan
|
|
345
|
+
az functionapp plan create \
|
|
346
|
+
--name myapp-plan \
|
|
347
|
+
--resource-group myapp-rg \
|
|
348
|
+
--location eastus \
|
|
349
|
+
--sku EP1
|
|
350
|
+
|
|
351
|
+
# Create function app on Premium plan
|
|
352
|
+
az functionapp create \
|
|
353
|
+
--name myapp \
|
|
354
|
+
--resource-group myapp-rg \
|
|
355
|
+
--plan myapp-plan \
|
|
356
|
+
--runtime python \
|
|
357
|
+
--storage-account myappstorage
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Dedicated (App Service) Plan
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Create App Service plan
|
|
364
|
+
az appservice plan create \
|
|
365
|
+
--name myapp-plan \
|
|
366
|
+
--resource-group myapp-rg \
|
|
367
|
+
--sku B1
|
|
368
|
+
|
|
369
|
+
# Create function app
|
|
370
|
+
az functionapp create \
|
|
371
|
+
--name myapp \
|
|
372
|
+
--resource-group myapp-rg \
|
|
373
|
+
--plan myapp-plan \
|
|
374
|
+
--runtime python \
|
|
375
|
+
--storage-account myappstorage
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## CI/CD Integration
|
|
379
|
+
|
|
380
|
+
### GitHub Actions
|
|
381
|
+
|
|
382
|
+
```yaml
|
|
383
|
+
# .github/workflows/azure-functions.yml
|
|
384
|
+
name: Deploy to Azure Functions
|
|
385
|
+
|
|
386
|
+
on:
|
|
387
|
+
push:
|
|
388
|
+
branches: [main]
|
|
389
|
+
|
|
390
|
+
env:
|
|
391
|
+
AZURE_FUNCTIONAPP_NAME: myapp
|
|
392
|
+
PYTHON_VERSION: '3.11'
|
|
393
|
+
|
|
394
|
+
jobs:
|
|
395
|
+
deploy:
|
|
396
|
+
runs-on: ubuntu-latest
|
|
397
|
+
|
|
398
|
+
steps:
|
|
399
|
+
- uses: actions/checkout@v3
|
|
400
|
+
|
|
401
|
+
- uses: actions/setup-python@v4
|
|
402
|
+
with:
|
|
403
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
404
|
+
|
|
405
|
+
- name: Install dependencies
|
|
406
|
+
run: |
|
|
407
|
+
python -m pip install --upgrade pip
|
|
408
|
+
pip install -r requirements.txt
|
|
409
|
+
|
|
410
|
+
- uses: azure/login@v1
|
|
411
|
+
with:
|
|
412
|
+
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
413
|
+
|
|
414
|
+
- name: Deploy to Azure Functions
|
|
415
|
+
uses: Azure/functions-action@v1
|
|
416
|
+
with:
|
|
417
|
+
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
|
418
|
+
package: .
|
|
419
|
+
scm-do-build-during-deployment: true
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Azure DevOps Pipeline
|
|
423
|
+
|
|
424
|
+
```yaml
|
|
425
|
+
# azure-pipelines.yml
|
|
426
|
+
trigger:
|
|
427
|
+
- main
|
|
428
|
+
|
|
429
|
+
pool:
|
|
430
|
+
vmImage: 'ubuntu-latest'
|
|
431
|
+
|
|
432
|
+
variables:
|
|
433
|
+
functionAppName: 'myapp'
|
|
434
|
+
pythonVersion: '3.11'
|
|
435
|
+
|
|
436
|
+
steps:
|
|
437
|
+
- task: UsePythonVersion@0
|
|
438
|
+
inputs:
|
|
439
|
+
versionSpec: '$(pythonVersion)'
|
|
440
|
+
|
|
441
|
+
- script: |
|
|
442
|
+
pip install -r requirements.txt
|
|
443
|
+
displayName: 'Install dependencies'
|
|
444
|
+
|
|
445
|
+
- task: ArchiveFiles@2
|
|
446
|
+
inputs:
|
|
447
|
+
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
|
|
448
|
+
includeRootFolder: false
|
|
449
|
+
archiveType: 'zip'
|
|
450
|
+
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
|
|
451
|
+
|
|
452
|
+
- task: AzureFunctionApp@1
|
|
453
|
+
inputs:
|
|
454
|
+
azureSubscription: 'Azure-Subscription'
|
|
455
|
+
appType: 'functionAppLinux'
|
|
456
|
+
appName: '$(functionAppName)'
|
|
457
|
+
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## Monitoring
|
|
461
|
+
|
|
462
|
+
### Application Insights
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
# Enable Application Insights
|
|
466
|
+
az monitor app-insights component create \
|
|
467
|
+
--app myapp-insights \
|
|
468
|
+
--location eastus \
|
|
469
|
+
--resource-group myapp-rg
|
|
470
|
+
|
|
471
|
+
# Link to Function App
|
|
472
|
+
APPINSIGHTS_KEY=$(az monitor app-insights component show \
|
|
473
|
+
--app myapp-insights \
|
|
474
|
+
--resource-group myapp-rg \
|
|
475
|
+
--query instrumentationKey -o tsv)
|
|
476
|
+
|
|
477
|
+
az functionapp config appsettings set \
|
|
478
|
+
--name myapp \
|
|
479
|
+
--resource-group myapp-rg \
|
|
480
|
+
--settings \
|
|
481
|
+
APPINSIGHTS_INSTRUMENTATIONKEY=$APPINSIGHTS_KEY
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### View Logs
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
# Stream logs
|
|
488
|
+
func azure functionapp logstream myapp
|
|
489
|
+
|
|
490
|
+
# Via Azure CLI
|
|
491
|
+
az webapp log tail \
|
|
492
|
+
--name myapp \
|
|
493
|
+
--resource-group myapp-rg
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Best Practices
|
|
497
|
+
|
|
498
|
+
1. **Use Consumption Plan**: For variable workloads
|
|
499
|
+
2. **Enable Application Insights**: Track all invocations
|
|
500
|
+
3. **Async/Await**: Use async functions for I/O operations
|
|
501
|
+
4. **Keep Functions Small**: Single responsibility
|
|
502
|
+
5. **Use Bindings**: Reduce boilerplate code
|
|
503
|
+
6. **Connection Pooling**: Reuse connections across invocations
|
|
504
|
+
7. **Error Handling**: Implement proper retry logic
|
|
505
|
+
8. **Cold Start Optimization**: Use Premium plan if needed
|
|
506
|
+
9. **Security**: Use managed identity for Azure resources
|
|
507
|
+
10. **Testing**: Write unit tests, use local runtime
|
|
508
|
+
|
|
509
|
+
## Troubleshooting
|
|
510
|
+
|
|
511
|
+
### Function Not Triggering
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
# Check function status
|
|
515
|
+
az functionapp function show \
|
|
516
|
+
--name myapp \
|
|
517
|
+
--resource-group myapp-rg \
|
|
518
|
+
--function-name HttpTrigger
|
|
519
|
+
|
|
520
|
+
# View logs
|
|
521
|
+
func azure functionapp logstream myapp
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Performance Issues
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
# Check execution times in Application Insights
|
|
528
|
+
# Consider Premium plan for:
|
|
529
|
+
# - VNet integration
|
|
530
|
+
# - Unlimited execution duration
|
|
531
|
+
# - Pre-warmed instances
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## Cost Optimization
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
# Consumption plan: Pay per execution
|
|
538
|
+
# - First 1M executions free
|
|
539
|
+
# - Optimize function duration
|
|
540
|
+
# - Use efficient triggers
|
|
541
|
+
|
|
542
|
+
# Premium plan: For predictable costs
|
|
543
|
+
# - Pre-warmed instances
|
|
544
|
+
# - No cold starts
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
## References
|
|
548
|
+
|
|
549
|
+
- [Azure Functions Documentation](https://docs.microsoft.com/azure/azure-functions/)
|
|
550
|
+
- [Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local)
|
|
551
|
+
- [Durable Functions](https://docs.microsoft.com/azure/azure-functions/durable/)
|
|
552
|
+
- [Functions Pricing](https://azure.microsoft.com/pricing/details/functions/)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# cloud.gov Deployment Module
|
|
2
|
+
|
|
3
|
+
Deft-native guidance for cloud.gov deployments, translated from the upstream
|
|
4
|
+
`adhocteam/cloud-gov-instructions` project (MIT License).
|
|
5
|
+
|
|
6
|
+
## Status
|
|
7
|
+
|
|
8
|
+
- ! Optional module
|
|
9
|
+
- ~ Good for Deft usage
|
|
10
|
+
- ~ Exportable for Copilot instructions
|
|
11
|
+
|
|
12
|
+
## Source & Attribution
|
|
13
|
+
|
|
14
|
+
This module is derived from `adhocteam/cloud-gov-instructions` **v1.1.0**.
|
|
15
|
+
See `deployments/cloud-gov/upstream/` for the pinned upstream snapshot.
|
|
16
|
+
|
|
17
|
+
License: MIT (see `deployments/cloud-gov/LICENSE.md`).
|
|
18
|
+
|
|
19
|
+
## Files
|
|
20
|
+
|
|
21
|
+
| File | Purpose |
|
|
22
|
+
|------|---------|
|
|
23
|
+
| `overview.md` | Repository-level cloud.gov overview |
|
|
24
|
+
| `deployment.md` | Deployment workflow & blue/green guidance |
|
|
25
|
+
| `manifest.md` | Manifest structure and best practices |
|
|
26
|
+
| `services.md` | Managed services and `VCAP_SERVICES` usage |
|
|
27
|
+
| `cicd.md` | CI/CD setup, service accounts, workflows |
|
|
28
|
+
| `security.md` | FedRAMP guidance, NIST control references |
|
|
29
|
+
| `logging.md` | Structured logging & log drains |
|
|
30
|
+
| `agents.md` | Agent behaviors & safety guardrails |
|
|
31
|
+
| `agents/compliance-docs.md` | Compliance documentation agent |
|
|
32
|
+
| `skills/cf-troubleshoot.md` | Troubleshooting skill |
|
|
33
|
+
|
|
34
|
+
## Tasks
|
|
35
|
+
|
|
36
|
+
Run these tasks from repo root:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
task cloudgov:sync
|
|
40
|
+
task cloudgov:export
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Export Output
|
|
44
|
+
|
|
45
|
+
Default export target: `.deft/cloud.gov/`
|
|
46
|
+
|
|
47
|
+
This generates Copilot-compatible files in:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
.deft/cloud.gov/
|
|
51
|
+
.github/
|
|
52
|
+
copilot-instructions.md
|
|
53
|
+
instructions/
|
|
54
|
+
agents/
|
|
55
|
+
skills/
|
|
56
|
+
AGENTS.md
|
|
57
|
+
LICENSE.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Notes
|
|
61
|
+
|
|
62
|
+
- ! Treat `.deft/cloud.gov/` as generated output (do not edit by hand)
|
|
63
|
+
- ~ Update `CLOUDGOV_VERSION` and `CLOUDGOV_EXTRACT_DIR` in `taskfiles/deployments.yml` to bump the pinned version
|