Skip to content

Detect and handle soft-delete resource conflicts during azd up #6794

Description

@spboyer

Problem

When users run azd up and a soft-deleted Azure resource exists with the same name as a resource being provisioned, ARM returns errors like FlagMustBeSetForRestore or Conflict. Users get a confusing error with no guidance on how to resolve it. Over 90 days, this accounted for ~3,237 errors (2.53%).

Current Behavior

azd has thorough soft-delete purge support during azd down (in pkg/infra/provisioning/bicep/bicep_provider.go, lines 980-1081). It handles 6 resource types: Key Vaults, Managed HSMs, Cognitive Services, App Configurations, API Management, and Log Analytics Workspaces. However, during azd up, there is no detection or handling of soft-delete conflicts.

Proposed Solution

  1. After a deployment failure, inspect the ARM error tree for soft-delete related error codes: FlagMustBeSetForRestore, Conflict with soft-delete context, AccountProvisioningStateInvalid
  2. When detected, check for soft-deleted resources matching the conflicting name using existing purge infrastructure (GetKeyVault, ListDeletedAccounts for Cognitive Services, etc.)
  3. Prompt the user: A soft-deleted <resource type> named '<name>' conflicts with this deployment. Purge it and retry? [y/N]
  4. Consider adding a --purge-on-conflict flag for non-interactive scenarios
  5. Key resource types to handle: Key Vaults, Cognitive Services accounts, App Configurations

Data Reference

Source: AzdProvisionErrorsByTemplate + AzdDeploymentErrorsByTemplate (DevCli on ddazureclients)

  • Resource Conflict / Soft Delete: 3,237 errors (2.53%)
  • Common ARM codes: Conflict, RequestConflict, FlagMustBeSetForRestore, ConflictError, ResourceGroupBeingDeleted

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions