Refactoring Plan
The deployment engine is testable and split into focused internal script shards loaded by scripts/AzureSqlVmToolkit.Deployment.psm1.
Target Internal Layout
Section titled “Target Internal Layout”Keep the public command surface unchanged:
New-AzureSqlVmToolkitDeploymentTest-AzureSqlVmToolkitConfigvm_creation_with_bastion.ps1as compatibility wrapper
The internals are split by responsibility:
scripts/AzureSqlVmToolkit.Deployment.Context.ps1: config loading, Azure context, predicted resource IDs, shared deployment state.scripts/AzureSqlVmToolkit.Deployment.Network.ps1: resource group, VNet, subnet, public IP, NSG, NIC, Bastion.scripts/AzureSqlVmToolkit.Deployment.Compute.ps1: VM creation/reuse, managed identity, VM image and size drift.scripts/AzureSqlVmToolkit.Deployment.Security.ps1: Key Vault, secrets, role assignments.scripts/AzureSqlVmToolkit.Deployment.Storage.ps1: storage account, file share, storage-key secret.scripts/AzureSqlVmToolkit.Deployment.GuestSetup.ps1: package script generation, Run Command, Azure Files mount, restore-helper upload.scripts/AzureSqlVmToolkit.Deployment.Orchestration.ps1: the high-level deployment order.
scripts/AzureSqlVmToolkit.Common.psm1 should keep general validation, output, password, naming, and low-level comparison helpers only.
Completed Refactoring Sequence
Section titled “Completed Refactoring Sequence”- Moved one responsibility at a time without changing behavior.
- Kept function names stable during the split.
- Ran local verification after the split:
.\scripts\Test-Local.ps1 -ConfigFile .\config.yaml- Added or changed tests only where movement exposed missing coverage.
- Updated architecture docs after the split landed.
Acceptance Criteria
Section titled “Acceptance Criteria”- Public command signatures remain unchanged.
-Plan,-WhatIf, and compatibility script behavior remain unchanged.- PSScriptAnalyzer and Pester remain clean.
- No internal module has mixed ownership across network, compute, security, storage, and guest setup.
- Live Azure tests remain a separate backlog item.
Clean GitHub Main Head Plan
Section titled “Clean GitHub Main Head Plan”Use main as the only release base:
- Finish fixes on
codex/azure-aware-release-process. - Push the branch.
- Open a PR into
main. - Wait for GitHub Actions:
Test toolkit, docs build, dependency audit, and CodeQL if enabled. - Squash merge into
mainonly after checks pass. - Fetch and switch local
maintoorigin/main. - Do not reset local divergent commits unless they are explicitly reviewed and no longer needed.
- Delete merged feature branches after confirming the PR is merged and the docs deployment is healthy.
If local main remains divergent, prefer creating future work branches from origin/main until that local branch is deliberately cleaned up.