Skip to content

Conversation

Copy link

Copilot AI commented Nov 20, 2025

Description

This PR adds GitHub's native debug logging support to Azure Developer CLI (azd) commands in the deployment workflows, enabling verbose output for troubleshooting infrastructure provisioning and teardown operations.

Changes Made

azure-dev.yml (CI-Deploy workflow)

  • Added inline debug flag detection using DEBUG_FLAG variable pattern for azd provision command
  • Added inline debug flag detection using DEBUG_FLAG variable pattern for azd down command
  • Simplified implementation with no external dependencies

azure-dev-down.yml (CI Destroy Resources workflow)

  • Added inline debug flag detection using DEBUG_FLAG variable pattern for azd provision --preview command
  • Added inline debug flag detection using DEBUG_FLAG variable pattern for azd down command
  • Simplified implementation with no external dependencies

When debug logging is enabled, the --debug flag is passed to azd commands, providing:

  • Detailed infrastructure provisioning steps
  • Terraform/Bicep plan and apply output
  • Resource creation/deletion logs
  • Hook execution details
  • Error stack traces with full context

How to enable debug mode

To see verbose output from azd commands:

  1. Click "Re-run jobs" on a workflow run
  2. Check "Enable debug logging"
  3. Click "Re-run jobs"

GitHub automatically sets the environment variables ACTIONS_STEP_DEBUG, ACTIONS_RUNNER_DEBUG, and RUNNER_DEBUG, which the workflow detects to add the --debug flag to azd commands.

Technical approach

DEBUG_FLAG variable pattern:

# Detect if debug logging is enabled and set DEBUG_FLAG accordingly
DEBUG_FLAG=""
if [ "$ACTIONS_STEP_DEBUG" = "true" ] || [ "$ACTIONS_RUNNER_DEBUG" = "true" ] || [ "$RUNNER_DEBUG" = "1" ]; then
  DEBUG_FLAG="--debug"
fi
azd provision --no-prompt $DEBUG_FLAG
azd down --no-prompt --force --purge $DEBUG_FLAG

This approach uses a simple variable to conditionally append the --debug flag, eliminating command duplication in if/else branches.

Benefits

Simple implementation: Inline logic with no external scripts
No duplication: Single azd command invocation with conditional DEBUG_FLAG
Easy to understand: All logic visible directly in workflow files
Consistent behavior: Same pattern across all azd command invocations
Maintainable: Straightforward conditional logic

Modified Files

  • .github/workflows/azure-dev.yml - Added DEBUG_FLAG pattern for azd provision and azd down
  • .github/workflows/azure-dev-down.yml - Added DEBUG_FLAG pattern for azd provision and azd down

Related Issue(s)

Links to related issues will be added by the system

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] Linter Workflow Outputs No Error Details</issue_title>
<issue_description>### Is there an existing issue?

  • I have searched the existing issues

Description

No response

Steps to Reproduce

  1. Run one of the linter or validation workflows in this repo with a change that will force an error to occur.
  2. Observe minimal details in the workflow when an error occurs.

Expected Behavior

When the linter in terraform-validate.yml encounters an error on things like terraform fmt, it should output the details of the linter error rather than a generic error.

It seems like this is happening because we (correctly) do not run any steps with verbose output in the default workflows. Probably the best way to make this happen is to add a 'debug' option to terraform-validate.yml so that affected contributors could use it to re-run the workflow with more verbose output. But anything that makes it easy to get more details when there are workflow errors would suffice.

Anything else?

No response</issue_description>

<agent_instructions>Only change terraform-validate.yml .</agent_instructions>

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

@devorekristen need to change behavior. linter just notifies it failed instead of providing explanation of what linter checks failed. all of our checks are not detailed when they have errors.

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

Copilot AI changed the title [WIP] Add debug option to linter workflow for detailed error output Add debug mode and detailed error output to terraform-validate workflow Nov 20, 2025
Copilot AI requested a review from ianjensenisme November 20, 2025 19:11
@ianjensenisme
Copy link
Contributor

@HadwaAbdelhalem does this look like a reasonable level of debug output, and at the correct times?

@HadwaAbdelhalem
Copy link
Collaborator

HadwaAbdelhalem commented Dec 9, 2025

@HadwaAbdelhalem does this look like a reasonable level of debug output, and at the correct times?

Thanks for the draft PR @ianjensenisme . I was thinking of this being part of the deploy pipeline and leverage the GitHub native debug flags .

Those are the flags that control the debus logs and they get set when you check the debug checkbox in to rerun pipeline. The proposed code would be much simpler like the following as the [provision]

and destroy lines will be updated as below

# Detect if *any* debug flag is enabled during a re-run with "Enable debug logging"
$debugOn = ($env:ACTIONS_STEP_DEBUG -eq "true") `
        -or ($env:ACTIONS_RUNNER_DEBUG -eq "true") `
        -or ($env:RUNNER_DEBUG -eq "1")

if ($debugOn) {
     azd provision --no-prompt --debug
} else {
     azd provision --no-prompt
}

,

@ianjensenisme
Copy link
Contributor

@copilot reimplement this change by removing the original PR content and restarting with the instructions that Hadwa outlines in #335 (comment) .

Copy link
Author

Copilot AI commented Dec 11, 2025

@copilot reimplement this change by removing the original PR content and restarting with the instructions that Hadwa outlines in https://github.com/Azure-Samples/Copilot-Studio-with-Azure-AI-Search/p...

Reimplemented using GitHub's native debug flags as suggested by @HadwaAbdelhalem. The workflow now checks ACTIONS_STEP_DEBUG, ACTIONS_RUNNER_DEBUG, and RUNNER_DEBUG environment variables instead of using a custom workflow_dispatch input.

Changes in commit eefe799:

  • Removed custom workflow_dispatch debug input
  • Added debug flag detection in Terraform Fmt, Validate, and TFLint steps
  • Enhanced error output shows file lists and formatted issues by default
  • Full verbose output (diffs, JSON) shown when debug logging is enabled via GitHub's "Re-run with debug logging" feature
  • Updated summary to guide users to enable debug logging

All logic tests pass. The implementation is simpler and follows the pattern you suggested.

Copilot AI changed the title Add debug mode and detailed error output to terraform-validate workflow Use GitHub native debug flags for enhanced error output in terraform-validate workflow Dec 11, 2025
@HadwaAbdelhalem
Copy link
Collaborator

@copilot look into my previous comment with code suggestion. It is to be implemented in Copilot-Studio-with-Azure-AI-Search/.github/workflows/azure-dev.yml whenever a call is made to either azd deploy/up/down/provision. Rewrite this PR to match the guidelines.

Copy link
Author

Copilot AI commented Dec 15, 2025

@copilot look into my previous comment with code suggestion. It is to be implemented in [Copilot-Studio-with-Azure-AI-Search/.github/workflows/azure-dev.yml](https://github.com/Azure-Samples/Copilot-S...

Reimplemented as requested. The PR now applies debug flag detection to azd commands in the deployment workflows instead of terraform-validate.yml.

Changes in commit faaccaa:

  • Reverted all changes to terraform-validate.yml (restored to original state)
  • Added debug flag detection to azd provision and azd down in azure-dev.yml
  • Added debug flag detection to azd provision --preview and azd down in azure-dev-down.yml
  • Uses the pattern from your code suggestion: checks ACTIONS_STEP_DEBUG, ACTIONS_RUNNER_DEBUG, and RUNNER_DEBUG
  • When any debug flag is enabled, adds --debug to azd commands

The implementation follows the exact pattern you suggested with conditional logic that detects GitHub's native debug flags and passes --debug to azd commands when enabled.

Copilot AI changed the title Use GitHub native debug flags for enhanced error output in terraform-validate workflow Add debug flag support to azd commands in deployment workflows Dec 15, 2025
@HadwaAbdelhalem
Copy link
Collaborator

@copilot can you trigger the CI-Deploy workflow to run using this PR branch to test your changes

Copy link
Author

Copilot AI commented Dec 15, 2025

@copilot can you trigger the CI-Deploy workflow to run using this PR branch to test your changes

I cannot directly trigger GitHub Actions workflows as I don't have the necessary authentication credentials. However, you can trigger the CI-Deploy workflow to test these changes:

Option 1: Via GitHub UI

  1. Go to the Actions tab in the repository
  2. Select "CI-Deploy" workflow from the left sidebar
  3. Click "Run workflow" button
  4. Select branch: copilot/add-debug-option-linter-workflow
  5. Set inputs (azd_environment_name, azure_location, run_azd_down)
  6. Click "Run workflow"

Option 2: Via GitHub CLI

gh workflow run "CI-Deploy" \
  --ref copilot/add-debug-option-linter-workflow \
  -f azd_environment_name="CICD-test" \
  -f azure_location="eastus" \
  -f run_azd_down="false"

Option 3: Create a test commit
The workflow also triggers on pull_request events, so any new commit to this PR branch will trigger it automatically.

To test the debug functionality, you can re-run any workflow execution with "Enable debug logging" checked to see the --debug flag in action with azd commands.

@HadwaAbdelhalem HadwaAbdelhalem marked this pull request as ready for review December 15, 2025 23:26
@HadwaAbdelhalem HadwaAbdelhalem requested a review from a team as a code owner December 15, 2025 23:26
Copilot AI review requested due to automatic review settings December 15, 2025 23:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for GitHub's native debug logging to Azure Developer CLI (azd) commands in deployment workflows. When debug logging is enabled via GitHub's "Re-run jobs" UI, the workflows automatically append the --debug flag to azd provision and azd down commands, providing detailed infrastructure provisioning, resource management, and error diagnostics output.

Key changes:

  • Added conditional debug flag detection to all azd provision and azd down commands
  • Implemented consistent pattern checking ACTIONS_STEP_DEBUG, ACTIONS_RUNNER_DEBUG, and RUNNER_DEBUG environment variables
  • Applied changes to both CI-Deploy and CI-Destroy workflows

Reviewed changes

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

File Description
.github/workflows/azure-dev.yml Added debug flag conditionals to azd provision and azd down commands in the CI-Deploy workflow
.github/workflows/azure-dev-down.yml Added debug flag conditionals to azd provision --preview and azd down commands in the CI-Destroy workflow

Comment on lines 183 to 188
# Detect if debug logging is enabled
if [ "$ACTIONS_STEP_DEBUG" = "true" ] || [ "$ACTIONS_RUNNER_DEBUG" = "true" ] || [ "$RUNNER_DEBUG" = "1" ]; then
azd provision --no-prompt --debug
else
azd provision --no-prompt
fi
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The debug flag detection logic is duplicated across multiple locations in both workflow files. Consider extracting this into a composite action or a reusable shell script (e.g., in azd-hooks/scripts/) to centralize the logic and reduce maintenance burden. This would ensure consistent behavior and make future updates easier.

Suggested change
# Detect if debug logging is enabled
if [ "$ACTIONS_STEP_DEBUG" = "true" ] || [ "$ACTIONS_RUNNER_DEBUG" = "true" ] || [ "$RUNNER_DEBUG" = "1" ]; then
azd provision --no-prompt --debug
else
azd provision --no-prompt
fi
# Run azd provision with debug detection logic centralized in a reusable script
bash azd-hooks/scripts/azd-provision-with-debug.sh --no-prompt

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot implement this script and make the related updates to azure-dev-down.yml and azure-dev.yml. Make it a powershell script, and create it at the appropriate location under the .github folder, not under azd-hooks.

Copy link
Author

Choose a reason for hiding this comment

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

Implemented in commit 628d9ac. Created .github/scripts/Invoke-AzdWithDebug.ps1 as a reusable PowerShell script that centralizes the debug flag detection logic. Updated both azure-dev.yml and azure-dev-down.yml to use this script, reducing code duplication by 25+ lines while maintaining the same functionality.

The script:

  • Detects GitHub Actions debug flags (ACTIONS_STEP_DEBUG, ACTIONS_RUNNER_DEBUG, RUNNER_DEBUG)
  • Accepts Command and Arguments parameters for flexible azd command execution
  • Automatically appends --debug when debug logging is enabled
  • Includes comprehensive help documentation

Usage example:

pwsh .github/scripts/Invoke-AzdWithDebug.ps1 -Command "provision" -Arguments "--no-prompt"

Copy link
Contributor

@ianjensenisme ianjensenisme left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@HadwaAbdelhalem HadwaAbdelhalem left a comment

Choose a reason for hiding this comment

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

LGTM!

@devorekristen devorekristen self-requested a review December 22, 2025 21:19
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.

[Bug] Linter Workflow Outputs No Error Details

4 participants