Skip to content

Add soft-delete detection preflight to prevent FlagMustBeSetForRestore failures #7263

@spboyer

Description

@spboyer

Problem

FlagMustBeSetForRestore accounts for 372 ARM deployment failures per month (7.9% of all InvalidTemplateDeployment errors) across 132 unique machines. Users deploy to a resource name that was previously soft-deleted, ARM requires createMode: restore or an explicit purge, and azd handles neither.

Telemetry Data (March 2026, 23 days)

Error Code Count Avg Wait Service
FlagMustBeSetForRestore 330 256s Container Apps (74), Functions (56), Key Vault, Cognitive Services
CanNotRestoreAnActiveResource 27 Mixed
CanNotRestoreANonExistingResource 15 Mixed
Total 372 242s avg 25 user-hours wasted/month

User Impact

  • Users wait an average of 4 minutes before receiving a soft-delete error
  • 65% retry without changing anything — retrying can never work without purging or restoring
  • These errors are 100% preventable with a preflight check

Proposed Solution

Add a preflight check in the provisioning pipeline that:

  1. Extracts resource names from the Bicep snapshot for soft-delete-capable resource types:
  2. If a name collision with a soft-deleted resource is found, prompt the user:
    • Purge — permanently delete the soft-deleted resource and proceed
    • Restore — recover the previous resource instead of creating new
    • Rename — use a different resource name
  3. This check runs alongside existing preflight checks (policy check in docs: local preflight — storage account policy check investigation #7179, quota check in Add quota and capacity pre-flight checks before ARM deployment #6800)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions