# Azure Pipelines: /azure-pipelines.yml: File /templates/build.yml not found in repository / Unable to find template

**Code:** `Template file not found` · **Category:** CI/CD · **Seen on:** Azure Pipelines

The YAML references a template (`template: templates/build.yml`) that Azure cannot find — wrong path, repo resource or branch.

## Meaning

Template paths are relative to the file that references them, unless they start with `/` (repo root). Templates in other repositories need a `resources: repositories:` entry and `@alias`. The branch the pipeline runs on must contain the file.

## Common causes

- Relative path wrong from the current file
- Leading `/` used but file is elsewhere
- Repository resource not declared or wrong `ref`
- File exists on a different branch only
- Typo in file name or case on Linux agents

## Quick fix

1. Fix the path relative to the current file or use `/` from repo root
2. Declare `resources.repositories` and use `template: file.yml@alias`
3. Commit the template to the branch being built

## Detailed fix by platform

### Azure DevOps

1. Reference: `- template: templates/build.yml@shared` after `resources: repositories: - repository: shared; type: git; name: Project/shared-repo`

## Code examples

### Template from another repo

```yaml
resources:
  repositories:
    - repository: shared
      type: git
      name: MyProject/shared-templates
steps:
  - template: build.yml@shared
```

## How to diagnose

1. **Path** — Relative or from root?
2. **Repo** — Resource declared?
3. **Branch** — File exists on this branch?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cicd/azure-template-not-found)
