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
- After a deployment failure, inspect the ARM error tree for soft-delete related error codes:
FlagMustBeSetForRestore, Conflict with soft-delete context, AccountProvisioningStateInvalid
- When detected, check for soft-deleted resources matching the conflicting name using existing purge infrastructure (
GetKeyVault, ListDeletedAccounts for Cognitive Services, etc.)
- Prompt the user:
A soft-deleted <resource type> named '<name>' conflicts with this deployment. Purge it and retry? [y/N]
- Consider adding a
--purge-on-conflict flag for non-interactive scenarios
- 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
Problem
When users run
azd upand a soft-deleted Azure resource exists with the same name as a resource being provisioned, ARM returns errors likeFlagMustBeSetForRestoreorConflict. 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(inpkg/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, duringazd up, there is no detection or handling of soft-delete conflicts.Proposed Solution
FlagMustBeSetForRestore,Conflictwith soft-delete context,AccountProvisioningStateInvalidGetKeyVault,ListDeletedAccountsfor Cognitive Services, etc.)A soft-deleted <resource type> named '<name>' conflicts with this deployment. Purge it and retry? [y/N]--purge-on-conflictflag for non-interactive scenariosData Reference
Source: AzdProvisionErrorsByTemplate + AzdDeploymentErrorsByTemplate (DevCli on ddazureclients)
Conflict,RequestConflict,FlagMustBeSetForRestore,ConflictError,ResourceGroupBeingDeleted