Skip to content

Add support for AVM pattern modules in Azure Terraform tools#2946

Open
liuwuliuyun wants to merge 4 commits into
microsoft:mainfrom
liuwuliuyun:support-for-pattern-modules
Open

Add support for AVM pattern modules in Azure Terraform tools#2946
liuwuliuyun wants to merge 4 commits into
microsoft:mainfrom
liuwuliuyun:support-for-pattern-modules

Conversation

@liuwuliuyun

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds support for AVM pattern modules (avm-ptn-*) to the Azure Terraform avm tools. Previously these tools only surfaced resource modules (avm-res-*) from TerraformResourceModules.csv. The service now also fetches TerraformPatternModules.csv (identical schema) and merges both into one collection.

  • azureterraform avm list returns both resource and pattern modules, each tagged with a new moduleType field ("resource" or "pattern").
  • azureterraform avm versions and azureterraform avm get work unchanged for pattern modules, since they already resolve a module by name from the merged collection and derive GitHub URLs from each module's RepoUrl.

No new commands or options — pattern modules are discoverable through the existing tools.

Implementation notes for reviewers:

  • Both CSVs are fetched in parallel (Task.WhenAll) and cached together under the existing 24h cache.
  • ParseModuleCsv gained a moduleType parameter to stamp each module; the pattern CSV has a leading BOM on its header, which is now stripped.
  • Verified end-to-end against live data: avm list returns 141 modules (112 resource + 29 pattern, correctly tagged); versions/get confirmed working for the avm-ptn-aca-lza-hosting-environment pattern module; resource modules unaffected (regression checked).

Documentation: Azure Verified Modules (Terraform) · Pattern module index

GitHub issue number?

N/A — no linked issue.

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

liuwuliuyun and others added 3 commits June 23, 2026 15:52
- Updated documentation to include pattern modules in CLI commands and examples.
- Enhanced command descriptions to clarify support for both resource and pattern modules.
- Modified data models and services to handle pattern modules, including parsing and fetching.
- Added tests for pattern module functionality and ensured proper handling in existing tests.
Add 'aiml' and 'feff' to the cspell dictionary (used by AVM pattern
module examples and the BOM-stripping escape) and remove a comment from
the AvmModule model to satisfy the no-comments-in-implementation rule.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds AVM pattern module (avm-ptn-*) discovery to the Azure Terraform AVM tools by fetching and merging the pattern-module CSV alongside the existing resource-module CSV, and exposing the module kind via a new moduleType field.

Changes:

  • Fetch TerraformResourceModules.csv and TerraformPatternModules.csv in parallel, merge, and cache the combined module collection.
  • Add ModuleType to AvmModule and stamp parsed modules as "resource" or "pattern" (including BOM stripping for the pattern CSV header).
  • Update tests, command descriptions, docs/examples, spelling dictionary, and add a changelog entry.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.AzureTerraform/src/Services/AvmDocsService.cs Fetch pattern-module CSV in parallel with resource-module CSV, merge results, stamp moduleType, strip BOM in header parsing.
tools/Azure.Mcp.Tools.AzureTerraform/src/Models/AvmModule.cs Add ModuleType field surfaced in responses.
tools/Azure.Mcp.Tools.AzureTerraform/tests/Azure.Mcp.Tools.AzureTerraform.Tests/AvmDocsServiceParsingTests.cs Add coverage for module typing and BOM header stripping.
tools/Azure.Mcp.Tools.AzureTerraform/tests/Azure.Mcp.Tools.AzureTerraform.Tests/AvmModuleListCommandTests.cs Validate response includes both resource and pattern module types.
tools/Azure.Mcp.Tools.AzureTerraform/src/Commands/AvmModuleListCommand.cs Update tool description to mention pattern modules and moduleType.
tools/Azure.Mcp.Tools.AzureTerraform/src/Commands/AvmVersionListCommand.cs Update tool description to mention pattern modules.
tools/Azure.Mcp.Tools.AzureTerraform/src/Commands/AvmDocumentationGetCommand.cs Update tool description to mention pattern modules.
tools/Azure.Mcp.Tools.AzureTerraform/src/AzureTerraformSetup.cs Update AVM group description to mention pattern modules.
servers/Azure.Mcp.Server/README.md Add example prompt for pattern-module docs.
servers/Azure.Mcp.Server/docs/e2eTestPrompts.md Add e2e prompts covering pattern module list/versions/get.
servers/Azure.Mcp.Server/docs/azmcp-commands.md Clarify avm list returns both resource and pattern modules.
servers/Azure.Mcp.Server/changelog-entries/avm-pattern-modules.yaml Changelog entry for new pattern-module support.
.vscode/cspell.json Add words used by new tests/implementation (aiml, feff).

Comment thread tools/Azure.Mcp.Tools.AzureTerraform/src/Services/AvmDocsService.cs Outdated
Comment thread tools/Azure.Mcp.Tools.AzureTerraform/src/Services/AvmDocsService.cs Outdated
Await the resource and pattern fetch tasks when reading their results
instead of blocking on Task.Result, and dispose the HttpResponseMessage
in FetchModulesAsync to avoid holding connections open.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants