Linked Templates and Template Nesting
What you'll learn: How to break apart large ARM templates into smaller, reusable pieces by linking them together.
As your Azure deployments grow complex, maintaining a single massive ARM template becomes unwieldy. Just like organizing code into separate files and functions, you can split ARM templates into modular pieces that reference each other.
The Core Idea
Linked templates let you call one ARM template from another using a special Microsoft.Resources/deployments resource. The main template references external templates stored in accessible locations (like Azure Storage or GitHub), passing parameters to them and receiving outputs back.
This is similar to how you might import modules in programming—your main template acts as an orchestrator that delegates specific responsibilities to specialized sub-templates.
Why Use Linked Templates?
- Modularity: Create reusable templates for common patterns (networking, storage, etc.)
- Team collaboration: Different teams can own different template components
- Size limits: ARM templates have a 4 MB size limit; linking helps you stay under it
- Maintainability: Smaller templates are easier to test, debug, and update
How It Works
Your parent template declares a deployment resource that points to a child template's URI. You pass parameters down and can reference outputs using the reference() function you already know. The child template must be accessible via HTTPS during deployment.
Think of it like a manager delegating tasks: the parent template says "deploy this networking infrastructure" and hands off that job to a specialized networking template, then waits for confirmation before proceeding.
Key Takeaway: Linked templates let you organize complex ARM deployments by connecting multiple templates together, enabling modularity, reuse, and better maintainability across large Azure infrastructure projects.