Subchapter 21.104
references/services/functions/templates/README.mdMarkdown7 KBView on GitHub
Dynamic template selection for Azure Functions projects.
Before proceeding, verify Azure MCP Server and Functions tools are available:
functions_template_get(language: "python")| Result | Action |
|---|---|
| ✅ Returns template list | Use Primary Path: MCP Tools below |
| ❌ Tool not found / Error | Jump to Fallback (MCP Unavailable) |
Use Azure MCP tools — they provide complete, up-to-date AZD templates with IaC, RBAC, and managed identity.
functions_template_get(language: "<python|csharp|typescript|javascript|java|powershell>")Returns template list with metadata:
templateName — pass to generate calldescription — use for selection (describes trigger, bindings, security features)resource — filter by trigger type (http, cosmos, timer, eventhub, blob, sql, mcp, ai)infrastructure — prefer bicep (default), use terraform if user requestsUse the intent→resource mapping in selection.md to map user intent to a resource filter value.
Default behavior: When user intent cannot be determined or no trigger type is known, use
httpas the default.
Single-template optimization: If description mentions BOTH trigger AND binding user needs, fetch that one template only.
IaC selection:
infrastructure: "bicep"infrastructure: "terraform"functions_template_get(
language: "<language>",
template: "<selected-template-name>"
)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 newas fallback when composing multiple recipes and required templates are not found in MCP.
Each array entry contains { path, content }. For every entry in BOTH arrays:
path (e.g., infra/ from infra/main.bicep, .azure/ from .azure/config.json). Create all unique parent directories first.path as the file path and content as the file body. Write every file exactly as specified.| Array | Contains | Action |
|---|---|---|
functionFiles[] | Function source code, infra, and config files | Write all — these are the trigger/binding code and IaC |
projectFiles[] | host.json, dependencies, settings files | Write all — these are runtime configuration |
PRESERVE generated IaC security patterns — keep RBAC, managed identity, and security config intact. When composing multiple templates, merge additively (see composition.md).
Skip content verification — MCP template files are pre-validated. After writing, do not
view/catfiles unless you customized them. Check success via exit code and file count only.
azd env set AZURE_LOCATION <region>
azd up --no-promptWhen user needs trigger + bindings not in a single template:
AzureWebJobsStorage exception: Always keep storage account + RBAC — runtime requires it.
If MCP tools are unavailable, download the CDN manifest which points to the same GitHub repos:
GET https://cdn.functions.azure.com/public/templates-manifest/manifest.json⚠️ If manifest fetch fails (any error):
- Fall back to the source manifest at
https://github.com/Azure/azure-functions-templates/blob/dev/Functions.Templates/Template-Manifest/manifest.json- 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)- If all fallbacks fail, report the error to the user and ask them to retry later
Each template entry contains:
| Field | Description | Example |
|---|---|---|
language | Programming language | Python, TypeScript, JavaScript, Java, CSharp, PowerShell |
resource | Trigger type (see selection.md) | http, cosmos, timer, eventhub, servicebus, blob, sql, mcp, durable |
iac | Infrastructure type | bicep, terraform |
repositoryUrl | GitHub repo with complete project | https://github.com/Azure-Samples/functions-quickstart-python-http-azd |
folderPath | Path within repo | . or src/api |
Filter: language == <user-lang> AND resource == <mapped-resource> AND iac == <user-iac>
If folderPath is . (root): ZIP download + unzip
GET https://github.com/{owner}/{repo}/archive/refs/heads/main.zip
unzip main.zip -d <project-dir>If folderPath is a subfolder: Fetch tree + raw file downloads
1. GET https://api.github.com/repos/{owner}/{repo}/git/trees/main?recursive=1
2. Filter tree entries where path starts with {folderPath}/
3. For each file:
GET https://raw.githubusercontent.com/{owner}/{repo}/main/{path}If downloads fail: Fall back to git clone
git clone <repositoryUrl> --depth 1
# If folderPath != ".", copy only that folderThe downloaded content is the same as MCP functionFiles[] + projectFiles[]:
azd up --no-promptBrowse all: Awesome AZD Functions (opens in a new tab)