Skip to content

Teardown & Cleanup

Delete all resource groups but keep the management group and policies:

Terminal window
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-wait
done

Wait for completion:

Terminal window
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/null
done

Also delete the budget (subscription-scoped, not in any RG):

Terminal window
az consumption budget delete --budget-name budget-smb-monthly

The Remove-SmbReadyFoundation.ps1 script handles complete cleanup:

Terminal window
cd infra/bicep/smb-ready-foundation
# Preview what will be deleted (dry run)
pwsh scripts/Remove-SmbReadyFoundation.ps1 -WhatIf
# Delete everything except management group
pwsh scripts/Remove-SmbReadyFoundation.ps1 -Force
# Delete everything including management group
pwsh scripts/Remove-SmbReadyFoundation.ps1 -Force -RemoveManagementGroup

The script removes:

  • 6 resource groups (with all contained resources)
  • Subscription-scoped budget
  • MG-scoped and subscription-scoped policy assignments
  • Management group itself (with -RemoveManagementGroup)
Terminal window
az group delete --name rg-hub-smb-swc --yes # replace swc with your region abbreviation
Terminal window
az group delete --name rg-spoke-prod-swc --yes # replace prod/swc as needed
Terminal window
# List current assignments
az policy assignment list \
--scope "/providers/Microsoft.Management/managementGroups/smb-rf" \
--query "[].{name:name, displayName:properties.displayName}" -o table
# Delete a specific policy
az policy assignment delete \
--name smb-compute-01 \
--scope "/providers/Microsoft.Management/managementGroups/smb-rf"

When switching scenarios, delete resource groups and budget but keep the MG and policies:

  1. Delete resource groups (parallel, async)
  2. Wait for deletions
  3. Delete budget
  4. Configure new scenario with azd env set SCENARIO <new-scenario>
  5. Deploy with azd up

Remove azd environment state (local only — does not delete Azure resources):

Terminal window
azd env select my-environment
azd env delete --force

List all environments:

Terminal window
azd env list

If you’re cleaning up a deployment you didn’t create, discover the deployed resources first:

Terminal window
# Find SMB Ready Foundation resource groups
az group list --query "[?starts_with(name,'rg-') && (contains(name,'smb') || contains(name,'spoke'))].{name:name, location:location}" -o table
# Check if the management group exists
az account management-group show --name smb-rf 2>/dev/null && echo "MG exists" || echo "No MG"
# Count policy assignments
az policy assignment list --scope "/providers/Microsoft.Management/managementGroups/smb-rf" --query "length(@)" 2>/dev/null