# azure/azure-functions-templates architecture

> Architecture diagram of the GitHub repository azure/azure-functions-templates, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure/azure-functions-templates
- Repository: https://github.com/azure/azure-functions-templates

## Overview

##### Project type and purpose
- This is a monorepo of “Azure Functions” templates (both script-type and pre-compiled .NET templates).
- Purpose: host, build, package, version and publish function-app starter templates consumed by Azure Functions Core Tools, Azure Portal, VS Code, Visual Studio, and Extension Bundles.

##### File structure
- Top-level directories:
- **Functions.Templates/** – raw template definitions (folders per trigger type, language).
- **Build/** – build scripts (gulp), package files (.nuspec), localization config.
- **Docs/** – markdown and JSON schema for metadata and actions.
- **Tools/** – helper console apps and scripts (e.g., CheckResourceStrings).
- **eng/** – CI configuration (YAML templates, builds).
- **Build artifacts**: package-lock.json, package.json for Node/Gulp.
- Patterns: separation of template definitions vs. build logic vs. docs vs. CI.
- Packaging: uses .nuspec files under Build/PackageFiles for .NET templates; extension-bundle nuspecs for script templates.

##### README for additional insights
- Build prerequisites (Node, Gulp) and steps (`gulp build-all`).
- Two template families: dotnet precompiled (project & item templates with .template.config) and script-type (metadata.json, bindings.json, resources.resx, sample.dat).
- Artifacts deployed:
- .nupkg for .NET (VS/VS Code/Core Tools)
- zip or static files for script templates (Extension Bundles).
- CI branches (dev, release/main) drive build and release.

a. Main components to include
- **Source Repository** – houses Functions.Templates, Docs, Build, Tools, eng
- **CI/CD Pipeline** – YAML templates in eng/ci trigger on commits/PRs
- **Build Engine** – Node + Gulp tasks (Build/gulpfile.js) that:
– compile .NET templates (into nupkg)
– bundle script templates (copy metadata, resx, code)
– generate documentation artifacts
- **Packaging** – .nuspec files produce:
– Dotnet Project & Item template packages (v3.x, v4.x, isolated)
– Extension Bundle packages (1.x–4.x, preview)
- **Artifact Repository / Feed** – NuGet feed for .NET, Static content for extension bundles
- **Consumers** – Azure Functions Core Tools, Azure Portal, Visual Studio Code, Visual Studio
- **Documentation Site** – Docs files used to generate schema reference / UI help
b. Relationships and interactions
– Developer commits → CI/CD triggers build → Build Engine runs Gulp → produces packages → publishes to feed/storage → Consumers fetch templates on “func new” or new-project wizard
– Tools/CheckResourceStrings validates resource keys → integrated in CI
– Docs schemas drive metadata.json and UI in clients
c. Architectural patterns/design principles
– **Separation of Concerns**: template definitions vs. build scripts vs. CI configs vs. docs
– **Content-Driven**: metadata-first approach (schema files drive UI prompts)
– **Versioned Packaging**: multiple nuspecs support side-by-side runtime versions
– **Automation**: CI templates make builds reproducible; Gulp tasks orchestrate multi-language packaging
d. Relevant technologies/frameworks/libraries
– Node.js & Gulp (Build pipeline)
– .NET templating engine (dotnet new)
– NuGet (.nuspec) for .NET templates
– JSON metadata, RESX for localization
– YAML for Azure Pipelines (eng/ci)
– PowerShell scripts for tooling (UpdateTemplatePackages.ps1)

##### Detail guidance
- Every folder group as a logical component (Functions.Templates, Build, Docs, Tools, eng)
- External dependencies: Node.js, .NET SDK, Azure DevOps
- Avoid over-splitting: group similar languages/triggers under one “Script Templates” component
- Packaging outputs and their targets (VS, VS Code, Portal, Core Tools, Extension Bundles)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Repository Components
    subgraph "Source Repository"
        SourceRepo["Source Repository"]:::repo
        subgraph "Template Definitions"
            FunctionsTemplates["Functions.Templates"]:::templates
            Bindings["Bindings Metadata & User Prompts"]:::templates
            ProjectV3["Project Templates v3.x"]:::templates
            ProjectV4["Project Templates v4.x"]:::templates
            ScriptsV2["Script-type Templates v2"]:::templates
            Scripts["Script-type Templates"]:::templates
            LocalizationBase["Resources.resx"]:::templates
            LocalizationLcl["Resources_lcl"]:::templates
        end
        subgraph "Documentation & Schemas"
            ActionsDocs["Action docs"]:::docs
            TemplateSchema["template-schema.json"]:::docs
            ActionSchemas["action-schemas.json"]:::docs
        end
        subgraph "Build Scripts & Config"
            BuildFolder["Build/"]:::buildconfig
        end
        subgraph "Tools"
            CheckRes["CheckResourceStrings"]:::tools
            UpdateTemplates["UpdateTemplatePackages.ps1"]:::tools
        end
        subgraph "CI/CD Configurations"
            LocalBuild["ci/templates/jobs/build.yml"]:::ci
            LocalizYML["ci/templates/jobs/localization.yml"]:::ci
            OfficialBuild["official-build.yml"]:::ci
            PublicBuild["public-build.yml"]:::ci
            CodeMirror["code-mirror.yml"]:::ci
        end
    end

    %% CI/CD Pipeline
    CI["CI/CD Pipeline"]:::ci

    %% Build Engine & Tasks
    subgraph "Build Engine (Node & Gulp)"
        Gulpfile["gulpfile.js"]:::build
        PackageJSON["package.json"]:::build
        PackageLock["package-lock.json"]:::build
        GulpUtils["gulp-utils"]:::build
    end

    %% Packaging Subsystem
    subgraph "Packaging"
        DotnetNuspec[".nuspec (Dotnet)"]:::package
        ExtBundleNuspec[".nuspec (ExtensionBundle)"]:::package
    end

    %% Artifact Repositories
    subgraph "Artifact Repositories"
        NuGetFeed["NuGet Feed"]:::repo
        StaticStorage["Extension Bundle Storage"]:::repo
    end

    %% Documentation Site
    DocumentationSite["Documentation Site"]:::docs

    %% Consumers
    subgraph "Consumers"
        CoreTools["Azure Functions Core Tools"]:::client
        Portal["Azure Portal"]:::client
        VSCode["Visual Studio Code"]:::client
        VisualStudio["Visual Studio"]:::client
    end

    %% Data Flow
    SourceRepo -->|"commits trigger"| CI
    CheckRes -->|"validates"| CI
    CI -->|"runs build"| Gulpfile
    Gulpfile --> PackageJSON
    Gulpfile --> PackageLock
    Gulpfile --> GulpUtils
    Gulpfile -->|"produces"| DotnetNuspec
    Gulpfile -->|"produces"| ExtBundleNuspec
    DotnetNuspec --> NuGetFeed
    ExtBundleNuspec --> StaticStorage
    TemplateSchema -.-> DocumentationSite
    ActionSchemas -.-> DocumentationSite
    ActionsDocs -.-> DocumentationSite
    DocumentationSite -->|"drives UI prompts"| CoreTools
    NuGetFeed --> CoreTools
    StaticStorage --> CoreTools
    NuGetFeed --> VSCode
    StaticStorage --> VSCode
    NuGetFeed --> VisualStudio
    StaticStorage --> VisualStudio
    NuGetFeed --> Portal
    StaticStorage --> Portal

    %% Click Events
    click SourceRepo "https://github.com/azure/azure-functions-templates/tree/dev//"
    click FunctionsTemplates "https://github.com/azure/azure-functions-templates/blob/dev//Functions.Templates"
    click Bindings "https://github.com/azure/azure-functions-templates/tree/dev//Functions.Templates/Bindings"
    click ProjectV3 "https://github.com/azure/azure-functions-templates/blob/dev//Functions.Templates/ProjectTemplate_v3.x"
    click ProjectV4 "https://github.com/azure/azure-functions-templates/blob/dev//Functions.Templates/ProjectTemplate_v4.x"
    click ScriptsV2 "https://github.com/azure/azure-functions-templates/tree/dev//Functions.Templates/Templates-v2"
    click Scripts "https://github.com/azure/azure-functions-templates/tree/dev//Functions.Templates/Templates"
    click LocalizationBase "https://github.com/azure/azure-functions-templates/blob/dev//Functions.Templates/Resources/Resources.resx"
    click LocalizationLcl "https://github.com/azure/azure-functions-templates/tree/dev//Functions.Templates/Resources_lcl"
    click Gulpfile "https://github.com/azure/azure-functions-templates/blob/dev//Build/gulpfile.js"
    click PackageJSON "https://github.com/azure/azure-functions-templates/blob/dev//Build/package.json"
    click PackageLock "https://github.com/azure/azure-functions-templates/blob/dev//Build/package-lock.json"
    click GulpUtils "https://github.com/azure/azure-functions-templates/tree/dev//Build/gulp-utils"
    click DotnetNuspec "https://github.com/azure/azure-functions-templates/blob/dev//Build/PackageFiles/Dotnet_precompiled/*.nuspec"
    click ExtBundleNuspec "https://github.com/azure/azure-functions-templates/blob/dev//Build/PackageFiles/ExtensionBundle/*.nuspec"
    click ActionsDocs "https://github.com/azure/azure-functions-templates/tree/dev//Docs/Actions"
    click TemplateSchema "https://github.com/azure/azure-functions-templates/blob/dev//Docs/Schema/template-schema.json"
    click ActionSchemas "https://github.com/azure/azure-functions-templates/blob/dev//Docs/Schema/action-schemas.json"
    click LocalBuild "https://github.com/azure/azure-functions-templates/blob/dev//eng/ci/templates/jobs/build.yml"
    click LocalizYML "https://github.com/azure/azure-functions-templates/blob/dev//eng/ci/templates/jobs/localization.yml"
    click OfficialBuild "https://github.com/azure/azure-functions-templates/blob/dev//eng/official-build.yml"
    click PublicBuild "https://github.com/azure/azure-functions-templates/blob/dev//eng/public-build.yml"
    click CodeMirror "https://github.com/azure/azure-functions-templates/blob/dev//eng/code-mirror.yml"
    click CheckRes "https://github.com/azure/azure-functions-templates/tree/dev//Tools/CheckResourceStrings"
    click UpdateTemplates "https://github.com/azure/azure-functions-templates/blob/dev//Tools/UpdateTemplatePackages.ps1"

    %% Styles
    classDef repo fill:#D0E6FF,stroke:#024F8E
    classDef templates fill:#E6FFE6,stroke:#1A7F1A
    classDef docs fill:#FFF9D6,stroke:#B38F00
    classDef build config fill:#FFD9B3,stroke:#B35C00
    classDef build fill:#FFE0B3,stroke:#CC8400
    classDef ci fill:#FFCCE5,stroke:#CC0080
    classDef package fill:#E0CCFF,stroke:#8000CC
    classDef tools fill:#F2F2F2,stroke:#888888
    classDef client fill:#E6E6E6,stroke:#666666
```
