Teardown & Cleanup
Quick Teardown (Resource Groups Only)
Section titled “Quick Teardown (Resource Groups Only)”Delete all resource groups but keep the management group and policies:
for rg in rg-hub-smb-swc rg-spoke-prod-swc rg-monitor-smb-swc rg-backup-smb-swc rg-migrate-smb-swc rg-security-smb-swc; do az group delete --name "$rg" --yes --no-waitdoneWait for completion:
for rg in rg-hub-smb-swc rg-spoke-prod-swc rg-monitor-smb-swc rg-backup-smb-swc rg-migrate-smb-swc rg-security-smb-swc; do az group wait --name "$rg" --deleted 2>/dev/nulldoneAlso delete the budget (subscription-scoped, not in any RG):
az consumption budget delete --budget-name budget-smb-monthlyFull Cleanup Script
Section titled “Full Cleanup Script”The Remove-SmbReadyFoundation.ps1 script handles complete cleanup:
cd infra/bicep/smb-ready-foundation
# Preview what will be deleted (dry run)pwsh scripts/Remove-SmbReadyFoundation.ps1 -WhatIf
# Delete everything except management grouppwsh scripts/Remove-SmbReadyFoundation.ps1 -Force
# Delete everything including management grouppwsh scripts/Remove-SmbReadyFoundation.ps1 -Force -RemoveManagementGroupThe script removes:
- 6 resource groups (with all contained resources)
- Subscription-scoped budget
- MG-scoped and subscription-scoped policy assignments
- Management group itself (with
-RemoveManagementGroup)
Selective Cleanup
Section titled “Selective Cleanup”Remove only hub networking
Section titled “Remove only hub networking”az group delete --name rg-hub-smb-swc --yes # replace swc with your region abbreviationRemove only the spoke
Section titled “Remove only the spoke”az group delete --name rg-spoke-prod-swc --yes # replace prod/swc as neededRemove policies only
Section titled “Remove policies only”# List current assignmentsaz policy assignment list \ --scope "/providers/Microsoft.Management/managementGroups/smb-rf" \ --query "[].{name:name, displayName:properties.displayName}" -o table
# Delete a specific policyaz policy assignment delete \ --name smb-compute-01 \ --scope "/providers/Microsoft.Management/managementGroups/smb-rf"Cleanup Between Scenario Tests
Section titled “Cleanup Between Scenario Tests”When switching scenarios, delete resource groups and budget but keep the MG and policies:
- Delete resource groups (parallel, async)
- Wait for deletions
- Delete budget
- Configure new scenario with
azd env set SCENARIO <new-scenario> - Deploy with
azd up
azd Environment Cleanup
Section titled “azd Environment Cleanup”Remove azd environment state (local only — does not delete Azure resources):
azd env select my-environmentazd env delete --forceList all environments:
azd env listDiscover an Existing Deployment
Section titled “Discover an Existing Deployment”If you’re cleaning up a deployment you didn’t create, discover the deployed resources first:
# Find SMB Ready Foundation resource groupsaz group list --query "[?starts_with(name,'rg-') && (contains(name,'smb') || contains(name,'spoke'))].{name:name, location:location}" -o table
# Check if the management group existsaz account management-group show --name smb-rf 2>/dev/null && echo "MG exists" || echo "No MG"
# Count policy assignmentsaz policy assignment list --scope "/providers/Microsoft.Management/managementGroups/smb-rf" --query "length(@)" 2>/dev/null