Skip to content

azd init should support .azdignore to exclude template files #4142

Description

@jongio

Problem

When running azd init --template <repo>, ALL files from the template repository are copied to the user's project directory. Template repos often contain files only relevant to template contributors -- not end consumers:

  • CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md
  • .github/workflows/azure-dev-validation.yaml (template CI)
  • CHANGELOG.md, CODEOWNERS

These files clutter the consumer's project and cause confusion.

Example: azure-ai-starter-basic copies CONTRIBUTING.md, CHANGELOG.md, .github/CODE_OF_CONDUCT.md, and .github/workflows/azure-dev-validation.yaml -- none of which an end-user needs.

Proposal

Add support for a .azdignore file at the template root that uses standard .gitignore syntax. Template authors add this file to exclude files/directories during azd init.

# .azdignore - files excluded when consumers run azd init
CONTRIBUTING.md
CODE_OF_CONDUCT.md
SECURITY.md
CHANGELOG.md
.github/workflows/azure-dev-validation.yaml

Design decisions

  • Separate file (not azure.yaml config) -- .gitignore syntax is universally understood
  • Root-only -- single .azdignore at template root, no recursive/nested ignore files
  • Self-excluding -- .azdignore itself is always removed from init output
  • UTF-8 BOM safe -- handles Windows editors that add BOM
  • Uses go-gitignore library (same as .funcignore, .webappignore, .gitignore support)

Relationship to other ignore features

Feature Phase Shipped
.azdignore azd init (template copy) This issue
.funcignore / .webappignore azd deploy (zip packaging) 1.18.0 (PR #5383)
.dockerignore azd deploy (docker build) Already supported

History

  • Original PR: #4146 (jongio, Jul 2024)
  • Revised PR: #4258 (jongio, Aug 2024, addressed review feedback)
  • Related: #7669, #1039, #4383

Metadata

Metadata

Assignees

Labels

area/core-cliCLI commands, cmd/, internal/cmd/enhancementNew feature or improvementstaleNo recent activity (bot-managed)

Fields

No fields configured for Feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions