Skip to content

Add Deployment TSG: clean up an existing Azure Local deployment before redeployment - #313

Open
AlBurns-MSFT wants to merge 6 commits into
Azure:mainfrom
AlBurns-MSFT:tsg/deployment-cleanup-before-redeploy
Open

Add Deployment TSG: clean up an existing Azure Local deployment before redeployment#313
AlBurns-MSFT wants to merge 6 commits into
Azure:mainfrom
AlBurns-MSFT:tsg/deployment-cleanup-before-redeploy

Conversation

@AlBurns-MSFT

Copy link
Copy Markdown
Collaborator

What

Adds a Deployment TSG documenting how to clean up an existing Azure Local (23H2+) deployment before redeployment: delete the Azure resources a deployment creates in a dependency-safe order (workload resources, then the Arc resource bridge, then the custom location, then the infrastructure resources), then reimage and redeploy.

This is a thinly documented procedure. The official Decommission Azure Local doc lists the resources to remove but not the deletion order, the cross-resource-group dependency check, or the CLI, verification, and troubleshooting steps this guide adds.

Files

  • TSG/Deployment/HowTo-Deployment-CleanUpBeforeRedeployment.md — new TSG
  • TSG/Deployment/README.md — registers the TSG in the Deployment index

Validation

Every claim was checked against Microsoft Learn, the Azure CLI reference, and the product docs; the on-cluster behaviors were confirmed against a live deployed Azure Local cluster.

  • Deletion order (Arc resource bridge, then custom location) is the documented Azure Local order: "The custom location should only be deleted after the Arc resource bridge has been deleted" (What is Azure Local VM management?, Components).
  • CLI commands verified against the current reference: az arcappliance delete hci --config-file, az customlocation delete, az keyvault purge, the az stack-hci-vm delete subgroups, and the az stack-hci-vm nic (attach/detach) vs az stack-hci-vm network nic (resource) distinction.
  • VM deletion side effects corrected to match the docs: deleting an Azure Local VM does not remove its network interfaces or data disks — those are deleted separately.
  • Resource inventory matches Decommission Azure Local.
  • Appliance-VM naming (*-control-plane-*) confirmed live: Get-VM on a deployed cluster returns a <GUID>-control-plane-0-<GUID> VM.

AlBurns-MSFT and others added 2 commits June 23, 2026 09:49
Adds a HowTo guide for TSG/Deployment covering the dependency-safe order to
delete a prior deployment's Azure resources before reimaging and redeploying,
so workload resources are removed before the Arc resource bridge and custom
location and no cloud resources are orphaned.

- Workload resources first (inside-out: disks/NICs before storage paths/logical
  networks), then Arc resource bridge, then custom location, then infrastructure
- Azure Resource Graph checkpoint (extendedLocation.name) to catch cross-RG
  dependents before deleting the platform resources
- Key Vault soft-delete/purge, ReadOnly/inherited locks, and stale Arc machine
  notes; no 22H2-era unregister cmdlet (23H2 removes the cluster via the
  Azure Local resource)
- Indexed in TSG/Deployment/README.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Step 3: deleting an Azure Local VM does not remove its network interfaces or
  data disks (delete them separately; add "Show hidden types" tip) -- per the
  Manage Azure Local VMs documentation.
- Step 4: cite the authoritative source for the Arc-resource-bridge-then-custom-
  location order (What is Azure Local VM management?) and note that
  az arcappliance delete hci is the supported bridge teardown.
- Replace two internal "Azure Local VMs wiki" references (not customer-accessible)
  with the Step 6 reimage and, for the no-reimage case, contact Microsoft Support.
- Add an Azure Resource Graph checkpoint caveat (scope = Directory, eventual-
  consistency lag) so a false "zero rows" cannot greenlight the irreversible delete.
- Soften "no separate unregister cmdlet" (Unregister-AzStackHCI still exists).
- Correct resource-lock inheritance scope (subscription, not management group).
- Widen the orphaned-VM workaround gating (the VM image and custom location must
  also still exist to recreate the VM).
Copilot AI review requested due to automatic review settings July 2, 2026 15:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Deployment How-To guide documenting how to clean up an existing Azure Local (23H2+) deployment before redeployment. It fills a gap in the official Decommission Azure Local documentation by prescribing a dependency-safe deletion order (workload resources → Arc resource bridge → custom location → infrastructure/registration resources), a cross-resource-group dependency checkpoint, CLI equivalents, verification, and troubleshooting. The guide follows the repository's HowTo-Template.md structure and is registered in the Deployment component index.

Changes:

  • Adds HowTo-Deployment-CleanUpBeforeRedeployment.md, a step-by-step TSG covering resource inventory, lock removal, ordered deletion, reimaging, verification, and troubleshooting.
  • Registers the new guide in TSG/Deployment/README.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
TSG/Deployment/HowTo-Deployment-CleanUpBeforeRedeployment.md New How-To guide detailing the dependency-safe cleanup procedure for redeploying Azure Local; follows the repo How-To template with valid TOC anchors, internal/external links, and CLI examples.
TSG/Deployment/README.md Adds an index entry linking to the new guide, consistent with existing entries.

I reviewed the template compliance, naming convention, README index entry, internal link (../ArcVMs/arc-vm-deletion.md exists), TOC anchor accuracy, external links (no version references), and CLI command accuracy. No blocking issues were found. Note that the guide documents destructive and irreversible Azure operations (deleting the Arc resource bridge, custom location, key vaults, and resource groups; purging soft-deleted vaults), so final technical validation against current Azure behavior is best confirmed by a human reviewer.

@aldawson33 aldawson33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The depth of this TSG does a great job of supplementing the 'official' procedure.

@1008covingtonlane

Copy link
Copy Markdown
Collaborator

TSG grader results, clean up a deployment before redeployment

I ran this through our TSG grader (static structure/safety lint plus a 13-reader persona usability panel). Strong, careful How-To: static lint B, usability 4.0/5. This is a procedural teardown, so there is no live inject/detect/mitigate loop to run; the feedback is doc usability plus one lint note.

Lint note (both warnings are doc-type artifacts, no action needed). The lint flagged "no symptoms section" and "no verify-the-fix step." The first does not apply to a How-To (there is no failure to symptomatize), and the guide does have a ## Verification section (the heuristic only matches the literal phrase "verify the fix"). All relative links resolve, so structurally it is sound.

Usability work items (highest-leverage first).

  • Add a top-of-document at-a-glance box (owner, downtime, irreversibility, rough time-to-complete) and lead with the most common scenario (failed deploy, then redeploy on the same hardware). (3 reviewers asked for this.)
  • Add a glossary (custom location, Arc resource bridge, extendedLocation, soft-delete and purge) for less-experienced operators.
  • Give the exact az delete commands per resource type in Step 3 as a copy-paste block, rather than describing the command groups in prose.
  • Add a one-line owner/scope note at the top so a mis-assigned reader routes on quickly.
  • Add a reminder to export or back up workload data before deletion, since the procedure is irreversible.
  • Cross-link the exact reimage / OS-install steps for the hardware in Step 6.

Nice touches already: the inside-out deletion order with the zero-rows Resource Graph checkpoint, the az arcappliance delete hci versus portal-delete distinction, and the Key Vault purge-to-reuse-the-name note are exactly the gotchas that bite people.

@1008covingtonlane

Copy link
Copy Markdown
Collaborator

Ran the 13-reader usability panel on this one: 4.0/5, a strong How-To. The dependency-safe inside-out deletion order, the zero-rows extendedLocation Resource Graph checkpoint, the az arcappliance delete hci versus portal-delete distinction, and the Key Vault purge-to-reuse-the-name note all landed well with the panel.

Five reader-driven items would take it to 5/5:

  1. Turn the Step 3 workload deletes from prose into an exact copy-paste az block, one command per resource type (az stack-hci-vm delete, image, network nic, disk, network nsg, storagepath, network lnet), matching the concrete style Step 4 already uses. This was the single most-requested item (five readers).
  2. A short glossary: custom location, Arc resource bridge, extendedLocation, soft-delete versus purge. (3 readers)
  3. A top-of-doc at-a-glance box: owner, downtime, irreversibility, rough time to complete. (2 readers)
  4. A reminder to back up or export workload data before the irreversible delete steps.
  5. Cross-link Step 6 to the exact reimage / OS-install procedure.

Optional polish from a reader already at 5: list the node-side EventIDs / logs to capture if a delete hangs. No correctness issues, this is all usability.

- Add at-a-glance rows to the header table (who runs it, reversibility,
  impact/downtime, estimated time)
- Add a Glossary (Arc resource bridge, custom location, extendedLocation,
  soft-delete vs. purge) and register it in the TOC
- Replace the Step 3 prose CLI description with an exact copy-paste
  `az stack-hci-vm` delete block, one verified command per resource type,
  in the inside-out deletion order
- Add a back-up-your-workload-data warning before the Step 3 deletes
- Cross-link Step 6 to the "Install the Azure Local operating system" doc

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AlBurns-MSFT

Copy link
Copy Markdown
Collaborator Author

Pushed a commit addressing the usability feedback:

  • Step 3 — exact az block: replaced the prose CLI description with a copy-paste az stack-hci-vm delete block, one command per resource type (delete, image delete, network nic delete, disk delete, network nsg delete, storagepath delete, network lnet delete) in the inside-out deletion order. Commands verified against the current Azure CLI reference.
  • Glossary: Arc resource bridge, custom location, extendedLocation, soft-delete vs. purge (also added to the TOC).
  • At-a-glance box: added header-table rows for who runs it, reversibility, impact/downtime, and estimated time.
  • Back-up reminder: a warning to export/back up workload data before the Step 3 deletes.
  • Step 6 cross-link: links the "Install the Azure Local operating system" doc for the reimage step.

I left out the optional "node-side EventIDs if a delete hangs" idea — I didn't have verified EventIDs and didn't want to publish unverified identifiers.

@Karl-WE

Karl-WE commented Jul 21, 2026

Copy link
Copy Markdown

I would like to add that the installation also creates a number of permission which then sprawl, especially seen on testing subscriptions.

Often these result into objects that cannot be resolved by Entra similar to unresolved SIDs in AD.

Personally I would appreciate a full script provided by Microsoft, at best as text for copy paste to az cli.
Either this could be done similar to Azure Migrate appliance, or Azure Portal linking to this TSG which also adds to the point making TSG more prominently known.

I am aware Portal changes often take a long time to come to prod for good reasons, so an aka.ms link in Port to TSG would be my preference.
Adding a button wipe and redeploy.

Risk: sometimes customers may use the witness storage account for multiple things.
Also Azure backup is not simply untied, as well as monitoring / Az Local insights.

Please check if the intention of cleanup is as thorough as intended.

AlBurns-MSFT and others added 3 commits July 26, 2026 18:55
…autions

Addresses the PR review (Karl-WE): the cleanup guide covered Azure resources but
not the objects a resource-group delete leaves behind. Adds, grounded in Microsoft
docs and a live read-only inspection of a real deployment:

- Step 1: callout that a deployment also creates Entra role assignments/identities,
  Azure Monitor config, and on-prem AD objects (not removed by an RG delete).
- Step 5b: untie Azure Monitor / Insights (DCR associations -> DCRs -> DCEs ->
  workspace) and, if enabled, Azure Backup (vault won't delete with soft-deleted items).
- Step 5c: remove orphaned "Identity not found" role assignments and the throwaway
  deployment principal; do NOT remove first-party RP service principals.
- Step 5d: clean up the on-prem AD OU/CNO/node/CAU/user objects, with a BitLocker
  recovery-key export warning before the recursive OU delete.
- Step 5: cloud-witness storage reuse + 2-node quorum caution.
- RG-delete note: those out-of-RG objects still require Steps 5b-5d.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n filter, warn on backup-data deletion

- Step 5b: associations are child resources removed with the machine (disabling Insights deletes them); drop the association delete commands and reword the survivors (DCRs/DCEs/alert rules/workspace/ingested data).
- Step 5b: raise the Azure Backup note to a WARNING; --delete-backup-data is irreversible and may be the last copy after Step 3.
- Step 5c: add an Entra directory-read precondition and a per-principal existence check (az ad sp/user show) before deleting, so an empty principalName from missing directory-read is not mistaken for orphans.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… guard, fix prerequisites

A source pass (public Windows AD docs + product source) and a fresh-SRE walkthrough
of the assembled doc drove these corrections:

- Step 5d: clear ProtectedFromAccidentalDeletion across the whole OU subtree
  (clearing the OU alone fails with Access Denied on any protected descendant), and
  add verify-scope-first, a -WhatIf preview, and a commented-out delete so copy-paste
  cannot over-scope the recursive removal.
- Step 5d: state it always applies (Azure Local 23H2 requires AD DS); realistic DN.
- Step 5c: separate operator-prerequisite roles (Owner or Contributor+UAA, RG-scoped)
  from deployment-created RG-scoped grants; surface the role-assignment id the delete needs.
- Prerequisites: Contributor alone cannot remove locks or role assignments; add Entra
  directory-read, Application/User Administrator, and the AD RSAT module.
- Step 3: warn that Azure Backup is the last copy, destroyed in Step 5b.
- Step 5b: cascade wording, DCR/DCE discovery hints, illustrative-command note.

Lint clean, fences balanced, anchors map, guarded AD block parses.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AlBurns-MSFT

Copy link
Copy Markdown
Collaborator Author

Addressed the review in the latest push. What was added, for the objects a resource-group delete leaves behind:

  • Orphaned identities (Step 5c): find and remove role assignments left as "Identity not found (Unknown)" after a deployment principal is deleted, confirming each principal is actually gone first (an empty principalName can just mean no directory-read), and leaving the Microsoft first-party resource-provider principals alone.
  • Witness storage (Step 5): confirm the cloud witness account is dedicated before deleting it; quorum-loss risk called out for a running two-node system.
  • Monitoring / Insights (Step 5b): remove the DCRs, DCEs, alert rules, and Log Analytics workspace that survive the machine delete (often in a separate resource group).
  • Azure Backup (Step 5b): the Recovery Services vault will not delete while backup items exist (including soft-deleted), and --delete-backup-data is irreversible.
  • On-prem AD (Step 5d): remove the deployment OU (CNO, node accounts, CAU object, users), clearing accidental-deletion protection across the whole subtree before the recursive delete, and export BitLocker recovery keys first.
  • Prerequisites: noted that Contributor alone cannot remove locks or role assignments, plus the directory-read and AD module requirements.

Commands are provided per step and marked to validate in-environment first; I did not exercise a full teardown end to end.

The portal wipe-and-redeploy button is a product ask rather than a doc change, so it is out of scope for this TSG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants