Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare Azure environments for new workloads—subscriptions, networking, identity, and landing zones
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/functions/templates/README.md
1# Azure Functions Templates23Dynamic template selection for Azure Functions projects.45## Prerequisites: Check MCP Availability67Before proceeding, verify Azure MCP Server and Functions tools are available:89```10functions_template_get(language: "python")11```1213| Result | Action |14|--------|--------|15| ✅ Returns template list | Use **Primary Path: MCP Tools** below |16| ❌ Tool not found / Error | Jump to **[Fallback (MCP Unavailable)](#fallback-mcp-unavailable)** |1718---1920## Primary Path: MCP Tools2122**Use Azure MCP tools** — they provide complete, up-to-date AZD templates with IaC, RBAC, and managed identity.2324### Step 1: Discover Templates2526```27functions_template_get(language: "<python|csharp|typescript|javascript|java|powershell>")28```2930Returns template list with metadata:3132- `templateName` — pass to generate call33- `description` — use for selection (describes trigger, bindings, security features)34- `resource` — filter by trigger type (http, cosmos, timer, eventhub, blob, sql, mcp, ai)35- `infrastructure` — prefer `bicep` (default), use `terraform` if user requests3637### Step 2: Select Template3839Use the intent→resource mapping in [selection.md](selection.md) to map user intent to a `resource` filter value.4041> **Default behavior:** When user intent cannot be determined or no trigger type is known, use `http` as the default.4243**Single-template optimization:** If description mentions BOTH trigger AND binding user needs, fetch that one template only.4445**IaC selection:**4647- Default: `infrastructure: "bicep"`48- If user says "terraform": `infrastructure: "terraform"`4950### Step 3: Generate Project5152```53functions_template_get(54language: "<language>",55template: "<selected-template-name>"56)57```5859### Step 4: Write All Files6061> Write files directly from the MCP tool output — CLI scaffolding tools produce incomplete projects missing IaC, RBAC, and managed identity configuration. NEVER hand-write Bicep/Terraform and use `azd init -t <template>`/`func init`/`func new` as fallback when composing multiple recipes and required templates are not found in MCP.6263Each array entry contains `{ path, content }`. For every entry in BOTH arrays:64651. **Create directories** — extract the parent directory from each `path` (e.g., `infra/` from `infra/main.bicep`, `.azure/` from `.azure/config.json`). Create all unique parent directories first.662. **Write the file** — use the `path` as the file path and `content` as the file body. Write every file exactly as specified.6768| Array | Contains | Action |69|-------|----------|--------|70| `functionFiles[]` | Function source code, infra, and config files | Write all — these are the trigger/binding code and IaC |71| `projectFiles[]` | host.json, dependencies, settings files | Write all — these are runtime configuration |7273**PRESERVE generated IaC security patterns** — keep RBAC, managed identity, and security config intact. When composing multiple templates, merge additively (see [composition.md](recipes/composition.md)).7475> **Skip content verification** — MCP template files are pre-validated. After writing, do not `view`/`cat` files unless you customized them. Check success via exit code and file count only.7677### Step 5: Deploy7879```bash80azd env set AZURE_LOCATION <region>81azd up --no-prompt82```8384---8586## Recipe Composition (Multiple Templates)8788When user needs trigger + bindings not in a single template:89901. **Discover** all templates for language912. **Select trigger template** as base (has complete project structure)923. **Select binding templates** for additional integrations934. **Fetch all** templates (parallel calls)945. **Compose**:95- Use trigger template as base96- Extract binding patterns from binding templates97- Merge IaC resources and RBAC roles98- Add user's custom logic996. **Trim** unused demo code from samples100101> **AzureWebJobsStorage exception**: Always keep storage account + RBAC — runtime requires it.102103---104105## Fallback (MCP Unavailable)106107If MCP tools are unavailable, download the CDN manifest which points to the same GitHub repos:108109### Step 1: Fetch Manifest110111```112GET https://cdn.functions.azure.com/public/templates-manifest/manifest.json113```114115> ⚠️ **If manifest fetch fails** (any error):116> 1. Fall back to the source manifest at `https://github.com/Azure/azure-functions-templates/blob/dev/Functions.Templates/Template-Manifest/manifest.json`117> 2. If both sources are unreachable, fall back to known-good repos: `Azure-Samples/functions-quickstart-*` keyed by language + resource (e.g., `functions-quickstart-python-http-azd`)118> 3. If all fallbacks fail, report the error to the user and ask them to retry later119120### Step 2: Filter Templates121122Each template entry contains:123124| Field | Description | Example |125|-------|-------------|---------|126| `language` | Programming language | `Python`, `TypeScript`, `JavaScript`, `Java`, `CSharp`, `PowerShell` |127| `resource` | Trigger type (see [selection.md](selection.md)) | `http`, `cosmos`, `timer`, `eventhub`, `servicebus`, `blob`, `sql`, `mcp`, `durable` |128| `iac` | Infrastructure type | `bicep`, `terraform` |129| `repositoryUrl` | GitHub repo with complete project | `https://github.com/Azure-Samples/functions-quickstart-python-http-azd` |130| `folderPath` | Path within repo | `.` or `src/api` |131132Filter: `language == <user-lang> AND resource == <mapped-resource> AND iac == <user-iac>`133134### Step 3: Download Template135136**If `folderPath` is `.` (root):** ZIP download + unzip137138```139GET https://github.com/{owner}/{repo}/archive/refs/heads/main.zip140unzip main.zip -d <project-dir>141```142143**If `folderPath` is a subfolder:** Fetch tree + raw file downloads144145```1461. GET https://api.github.com/repos/{owner}/{repo}/git/trees/main?recursive=11472. Filter tree entries where path starts with {folderPath}/1483. For each file:149GET https://raw.githubusercontent.com/{owner}/{repo}/main/{path}150```151152**If downloads fail:** Fall back to git clone153154```bash155git clone <repositoryUrl> --depth 1156# If folderPath != ".", copy only that folder157```158159The downloaded content is the **same** as MCP `functionFiles[]` + `projectFiles[]`:160161- Source code (function triggers, bindings)162- IaC (Bicep/Terraform with RBAC, managed identity)163- azure.yaml (azd configuration)164- host.json, dependencies165166### Step 4: Deploy167168```bash169azd up --no-prompt170```171172---173174## References175176- [Composition Details](recipes/composition.md) — recipe algorithm177- [Selection Guide](selection.md) — intent→resource mapping178- [Recipes Index](recipes/README.md) — all available recipes179- [Base Template Eval](base/eval/summary.md) — HTTP base evaluation results180181**Browse all:** [Awesome AZD Functions](https://azure.github.io/awesome-azd/?tags=functions)182