Draft
Implement Remove-AzBootstrapEnvironment function with comprehensive cleanup and interactive mode#48
Conversation
…prehensive tests Co-authored-by: kewalaka <3146590+kewalaka@users.noreply.github.com>
Co-authored-by: kewalaka <3146590+kewalaka@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] issue: Remove-AzBootstrapEnvironment needs re-instating
Implement Remove-AzBootstrapEnvironment function with comprehensive cleanup and interactive mode
May 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the
Remove-AzBootstrapEnvironmentfunction to provide complete environment removal capabilities, addressing the functionality that was previously removed when focusing on Bicep-based resource creation.Changes
New Functions Added
Remove-AzBootstrapEnvironment(public) - Main orchestrator function with both parameter-based and interactive modesGet-AzBootstrapEnvironmentConfig(private) - Reads environment configuration from.azbootstrap.jsonctracking fileRemove-GitHubEnvironment(private) - Deletes GitHub environments via GitHub APIRemove-AzDeploymentStack(private) - Removes Azure deployment stacks with automatic resource cleanupRemove-AzBootstrapConfig(private) - Updates configuration file to remove environment entriesKey Features
Interactive Mode: When no environment name is provided, the function displays available environments from the tracking file and allows selection by number or name:
Parameter-based Mode: Direct specification of environment and repository details:
Comprehensive Cleanup: The function removes:
.azbootstrap.jsonctracking fileRobust Error Handling: Continues cleanup operations even if individual steps fail, ensuring maximum resource cleanup with appropriate warnings.
Implementation Details
.azbootstrap.jsonctracking file introduced in Add .azbootstrap.jsonc tracking file to monitor resources under az-bootstrap control #32 to identify managed resourcesAdd-AzBootstrapEnvironmentfor consistencyWhatIfandConfirmparameters for safe operationTesting
Added comprehensive test coverage with 13 new tests:
Test-GetAzBootstrapEnvironmentConfig.Tests.ps1- Configuration file readingTest-RemoveGitHubEnvironment.Tests.ps1- GitHub environment deletionTest-RemoveAzBootstrapConfig.Tests.ps1- Configuration file updatesTest-RemoveAzBootstrapEnvironment.Tests.ps1- Main function integrationAll existing tests continue to pass, ensuring no regressions.
Documentation
Updated
README.mdwith:Usage Examples
The implementation provides a clean, user-friendly way to remove environments while ensuring thorough cleanup of both Azure and GitHub resources.
Fixes #16.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.