feat: add local preflight validation before bicep deployment#7053
feat: add local preflight validation before bicep deployment#7053
Conversation
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a client-side preflight validation stage (azd provision) that runs after Bicep compilation but before deployment. It parses the ARM template, uses bicep snapshot to get a fully-resolved resource graph, and runs pluggable check functions — starting with an RBAC role-assignment permission check.
Changes:
- New
local_preflight.goengine: ARM template parsing, snapshot-based resource analysis, pluggable check pipeline - New
permissions.goinpkg/azapi: RBAC action matching with wildcard support (PermissionsService.HasRequiredPermissions) - New
preflight_report.goUX component and associated tests BicepProvider.Deploy()integrates the local preflight stage and replacesuserConfigManagerwith aserviceLocatorprompter.go: removesDefaultValuepre-selection from resource group picker (unrelated regression)
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
bicep_provider.go |
Integrates local preflight into Deploy(), adds checkRoleAssignmentPermissions, switches from userConfigManager field to serviceLocator for lazy resolution |
local_preflight.go |
New preflight engine: ARM template parsing, temp .bicepparam generation, bicep snapshot invocation, check pipeline |
permissions.go |
New RBAC PermissionsService with wildcard-aware actionMatches |
preflight_report.go |
New UxItem for rendering preflight warnings/errors |
bicep.go |
New Snapshot() method and SnapshotOptions builder |
prompter.go |
Unrelated: removes DefaultValue pre-selection from resource group picker prompt |
container.go |
Registers NewPermissionsService as singleton |
bicep_provider_test.go |
Updates test helper to pass mockContext.Container for serviceLocator |
| Test files | New unit tests for parsing, check pipeline, RBAC matching, generateBicepParam, and PreflightReport |
local-preflight-validation.md |
Design doc for the feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
wbreza
left a comment
There was a problem hiding this comment.
📋 Code Review — PR #7053
Solid foundation for local preflight validation. The AddCheck() pipeline pattern and graceful degradation are well-designed. However, this needs architectural changes to be extensible from day one.
I analyzed this against the existing azd extension framework and found that the infrastructure for extensible preflight already exists — preprovision event hooks, gRPC bidirectional streaming, and the EventDispatcher pattern. This feature should build on that foundation rather than hardcoding validation inside BicepProvider.Deploy().
✅ What Looks Good
AddCheck()pipeline pattern is composable and clean- Graceful degradation when
bicep snapshotfails (logs warning, doesn't block) - Clear severity model: Warning (user prompted) vs Error (auto-abort)
PermissionsServiceis properly separated and reusable inpkg/azapi/- Wildcard matching for RBAC actions is well-implemented with good tests
- Design doc is thorough and well-written
Summary
| Priority | Count |
|---|---|
| High | 2 |
| Medium | 2 |
| Total | 4 |
Overall Assessment: Request Changes — The core validation logic is sound, but the architecture needs to be designed for extensibility from the start. Key changes: (1) use preprovision hooks instead of hardcoding in BicepProvider, making this provider-agnostic, (2) parallelize check execution for when multiple checks are registered, and (3) build with the mindset that extension authors will add custom validators in the future.
|
Clarification on the review above: The "Request Changes" state was overly strong — this should have been posted as a Comment. To be clear: the core validation logic and AddCheck() pipeline are solid. Full extension framework integration can come later — the ask is to design the architecture with that future path in mind so we don't need a major refactor when we get there. Specifically:
These are structural suggestions to avoid painting ourselves into a corner. The underlying validation logic is great work. |
tg-msft
left a comment
There was a problem hiding this comment.
This looks great! I'm excited to get it in and start experimenting.
reviewed offline - moving on with the changes and creating follow up actions
|
/check-enforcer evaluate |
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
) * Initial plan * feat: add local preflight validation with golangci-lint issues fixed Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> * fix: address review feedback - nil panic, spinner, wildcards, snapshot degradation, prompter Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
*DeployResult{SkippedReason: PreflightAbortedSkipped}on preflight abort; guard inmanager.goto skip nil Deployment processinginput.StepSkippedinstead ofinput.StepFailedfor intentional deployment abortactionMatches: replaced single-wildcard handling withwildcardMatchsupporting any number of*wildcards; added test casesbicep snapshotfails: log warning and return empty results instead of blocking deploymentDefaultValuepre-selection inprompter.go(regression fix)Original prompt
continue
[Chronological Review: The conversation began with the user requesting a summary of changes on a specific branch, referencing a file for context. The user then requested to fix issues identified by `golangci-lint`, repeating this request multiple times. The user also issued a command to delegate tasks, indicating a desire for assistance in resolving the linting issues.][Intent Mapping:
[Technical Inventory:
golangci-lint- A Go linter that checks for various issues in Go code./home/vivazqu/workspace/azure-dev/cli/azd/pkg/infra/provisioning/bicep/local_preflight.go- The current file being worked on, likely containing Go code that needs linting.][Code Archaeology: No specific code changes were documented in the conversation, but the focus has been on resolving linting issues in the specified Go file.]
[Progress Assessment:
golangci-lintand has made multiple requests to fix the identified issues.[Context Validation: The conversation captures the user's ongoing struggle with linting issues in their Go code and their requests for assistance in resolving these issues.]
[Recent Commands Analysis:
golangci-lintand requested to delegate tasks.golangci-lintrun have not been explicitly detailed in the conversation, but the user has indicated that issues remain unresolved.1. Conversation Overview: - Primary Objectives: - "make a summary from the changes on this branch." - User seeks a summary of branch changes. - "fix the issues from golangci-lint run ./..." - User wants to resolve linting issues in their Go code. - Session Context: The conversation has focused on addressing linting issues in a specific Go file, with the user expressing frustration over unresolved problems. - User Intent Evolution: The user has consistently requested assistance with linting issues, indicating a need for support in resolving these technical challenges.- Technical Foundation:
- Tool:
- Environment Detail: The user is working within a Go project located at
- Codebase Status:
- File Name:
- Purpose: This file is part of the provisioning logic in the Azure Dev CLI project.
- Current State: The user has attempted to run linting checks but has not successfully resolved the issues.
- Key Code Segments: Specific functions or classes were not detailed in the conversation.
- Dependencies: The file is part of a larger Go project, likely interacting with other components in the Azure Dev CLI.
- Problem Resolution:
- Issues Encountered: The user is facing unresolved linting issues as identified by
- Solutions Implemented: The user has attempted to fix these issues but has not succeeded, as indicated by repeated requests to "Try Again."
- Debugging Context: The user is actively seeking help to resolve these linting problems.
- Lessons Learned: The user may need additional support or a different approach to address the linting issues effectively.
- Progress Tracking:
- Completed Tasks: The user has run
- Partially Complete Work: The user has not yet resolved the linting issues.
- Validated Outcomes: No features or code have been confirmed working due to ongoing linting problems.
- Active Work State:
- Current Focus: The user is focused on fixing linting issues in
- Recent Context: The user has repeatedly requested to fix linting issues and has expressed frustration with the process.
- Working Code: The specific code being modified was not detailed, but it pertains to the Go file in question.
- Immediate Context: The user was actively trying to resolve linting issues when the token budget was exceeded.
- Recent Operations:
- Last Agent Commands: User commands included fixing linting issues and delegating tasks.
- Tool Re...
golangci-lint- A Go linter used to identify issues in Go code./home/vivazqu/workspace/azure-dev/cli/azd/pkg/infra/provisioning/bicep/local_preflight.go.local_preflight.gogolangci-lint.golangci-lintand made multiple requests for fixes.local_preflight.go.Created from VS Code.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.