Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Support azure.yml in addition to azure.yaml

✅ Implementation Complete

This PR adds support for both azure.yml and azure.yaml file names in the Azure Developer CLI and VS Code extension, addressing issue #542.


Changes Made

Go CLI (cli/azd/pkg/environment/azdcontext/azdcontext.go)

  • ✅ Added ProjectFileNames variable listing both valid file names in preference order
  • ✅ Modified NewAzdContextFromWd to search for all valid project file names
  • ✅ Updated ProjectPath() to return the actual file found with clear documentation
  • ✅ When both files exist, azure.yaml takes precedence (backward compatible)
  • ✅ Proper error handling for unexpected file system errors (not just NotExist)
  • Comprehensive unit tests added (cli/azd/pkg/environment/azdcontext/azdcontext_test.go)

VS Code Extension

ext/vscode/package.json:

  • ✅ Updated context menu triggers to recognize both file extensions (/azure.ya?ml/i)
  • ✅ Added YAML schema validation for both azure.yaml and azure.yml

ext/vscode/src/commands/cmdUtil.ts:

  • ✅ Updated glob pattern to search for both extensions (case-insensitive)
  • ✅ Updated error messages to mention both file types
  • ✅ Updated documentation comments

Testing & Verification

Unit Tests (cli/azd/pkg/environment/azdcontext/azdcontext_test.go)

  • 16 test cases covering all functionality:
    • Finding azure.yaml files
    • Finding azure.yml files
    • Precedence when both files exist (azure.yaml takes priority)
    • Walking up from subdirectories to find project files
    • Handling missing project files (returns ErrNoProject)
    • Handling directories with same name as project files
    • ProjectPath() behavior with and without found files
    • Helper methods (SetProjectDirectory, EnvironmentDirectory, etc.)
    • ProjectFileNames order and contents validation
    • ProjectName function with various inputs
  • ✅ All tests pass with 50% code coverage
  • ✅ 0 linting issues (golangci-lint, gosec)

Automated Tests

  • ✅ All existing Go tests pass
  • ✅ All new unit tests pass (16/16)
  • ✅ Manual tests verify both file extensions work correctly:
    • azure.yaml only → ✓ recognized
    • azure.yml only → ✓ recognized
    • Both files present → ✓ azure.yaml takes precedence
    • Subdirectory navigation → ✓ works with both extensions
    • No project file → ✓ proper error message
    • Directory with same name → ✓ properly skipped

Code Quality

  • gofmt passed
  • golangci-lint passed (0 issues)
  • cspell passed
  • package.json validated
  • ✅ Code review feedback addressed

Security Review

  • ✅ No file path traversal vulnerabilities
  • ✅ No injection risks (SQL, command, script)
  • ✅ Proper error handling for all file operations
  • ✅ No secrets or sensitive data exposure
  • ✅ Uses safe filepath operations
  • ✅ Secure file permissions (0600) in tests

Backward Compatibility

Fully backward compatible:

  • Existing projects with azure.yaml continue to work without changes
  • New projects default to generating azure.yaml
  • No breaking changes to APIs or behavior
  • Existing VS Code context menus work identically

Implementation Details

File Discovery Logic:

  1. Searches for project files in order of preference: azure.yaml, then azure.yml
  2. Walks up directory tree until a valid project file is found
  3. Returns the first matching file, maintaining preference order
  4. Falls back to azure.yaml when generating new projects
  5. Properly handles unexpected file system errors (permissions, I/O errors, etc.)

VS Code Pattern Matching:

  • Uses case-insensitive character classes: **/[aA][zZ][uU][rR][eE].{[yY][aA][mM][lL],[yY][mM][lL]}
  • Matches all case variations: azure.yaml, Azure.Yml, AZURE.YML, etc.
  • Maintains original case-insensitive behavior

Security Summary

No security vulnerabilities introduced. All changes use safe file operations with proper error handling.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support azure.yml in addition to azure.yaml</issue_title>
<issue_description>See the discussion in #542 (comment). When we do this, we should go fix the glob back up and also ensure that the context menu commands show up for azure.yml in addition to azure.yaml.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Updated Go code to search for both azure.yaml and azure.yml files
- azure.yaml takes precedence when both files exist
- Updated VS Code extension context menus to show for both file extensions
- Updated glob patterns and validation schemas for both file names
- Updated error messages to mention both file extensions

Co-authored-by: spboyer <[email protected]>
Copilot AI and others added 2 commits November 25, 2025 19:55
- Add clarifying comment to ProjectPath() method explaining its dual behavior
- Fix VS Code glob pattern to be case-insensitive using character classes
- Pattern now correctly matches azure.yaml, azure.yml, AZURE.YAML, Azure.Yml, etc.

Co-authored-by: spboyer <[email protected]>
Copilot AI changed the title [WIP] Support azure.yml format alongside azure.yaml Support azure.yml in addition to azure.yaml Nov 25, 2025
Copilot AI requested a review from spboyer November 25, 2025 20:03
Copilot finished work on behalf of spboyer November 25, 2025 20:03
bwateratmsft

This comment was marked as outdated.

Copy link
Contributor

@bwateratmsft bwateratmsft left a comment

Choose a reason for hiding this comment

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

VSCode parts look fine. Someone else, please review the Go code, I'm not well-qualified to do that! I'm guessing that Copilot shouldn't be touching go.mod and go.sum but don't know for sure.

@spboyer
Copy link
Member

spboyer commented Dec 1, 2025

VSCode parts look fine. Someone else, please review the Go code, I'm not well-qualified to do that! I'm guessing that Copilot shouldn't be touching go.mod and go.sum but don't know for sure.

Probably right about that. :-)

@spboyer
Copy link
Member

spboyer commented Dec 1, 2025

@copilot - why change go.mod file is the modified? Is there a dependency change? go.sum - lockfile and should not be manually altered.

These files are manifest/lockfiles managed by the Go toolchain and should not be manually modified. Restored them to their original state before my changes.

Co-authored-by: spboyer <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

@copilot - why change go.mod file is the modified? Is there a dependency change? go.sum - lockfile and should not be manually altered.

Reverted go.mod and go.sum to their original state in commit 2292716. These files are now unchanged from the base branch.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd env list (dns block)
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd telemetry upload (dns block)
  • westus-0.in.applicationinsights.azure.com
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd telemetry upload (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of spboyer December 1, 2025 17:37
Added proper error handling to return errors from os.Stat that are not os.ErrNotExist. This ensures unexpected file system errors (e.g., permission issues) are properly propagated instead of being silently ignored.

Co-authored-by: weikanglim <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd env list (dns block)
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd telemetry upload (dns block)
  • westus-0.in.applicationinsights.azure.com
    • Triggering command: /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd /home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd telemetry upload (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from weikanglim December 1, 2025 19:37
Copilot finished work on behalf of weikanglim December 1, 2025 19:37
// ProjectPath returns the path to the project file. If the context was created by searching
// for a project file, returns the actual file that was found. Otherwise, returns the default
// project file name joined with the project directory (useful when creating new projects).
func (c *AzdContext) ProjectPath() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot - please add some unit tests to validate this existing and new behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comprehensive unit tests in commit f298fdf. The test suite includes 16 test cases covering:

  • Finding azure.yaml and azure.yml files
  • Precedence behavior (azure.yaml over azure.yml)
  • Subdirectory navigation
  • Error handling (missing files, invalid paths)
  • Edge cases (directories with same name as project files)
  • All helper methods

All tests pass with 0 linting issues.

Added unit tests to validate:
- Finding azure.yaml files
- Finding azure.yml files
- Precedence when both files exist (azure.yaml takes priority)
- Walking up from subdirectories
- Handling missing project files (returns ErrNoProject)
- Handling directories with same name as project files
- ProjectPath() behavior with and without found files
- Helper methods (SetProjectDirectory, EnvironmentDirectory, etc.)
- ProjectFileNames order and contents

All tests pass with 0 linting issues.

Co-authored-by: wbreza <[email protected]>
Copilot finished work on behalf of wbreza December 1, 2025 21:44
Copilot AI requested a review from wbreza December 1, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support azure.yml in addition to azure.yaml

5 participants