{"record":{"id":"78ada6e7b654b547","repo":"microsoft/aspire","slug":"destroy-operation-canceled-by-user","errorCode":null,"errorMessage":"Destroy operation canceled by user.","messagePattern":"Destroy operation canceled by user\\.","errorType":"exception","errorClass":"OperationCanceledException","httpStatus":null,"severity":"info","filePath":"src/Aspire.Hosting.Azure/AzureEnvironmentResource.cs","lineNumber":353,"sourceCode":"                : $\"Delete resource group '{resourceGroupName}'? This action cannot be undone.\";\n\n            var result = await interactionService.PromptNotificationAsync(\n                \"Destroy Azure resources\",\n                confirmMessage,\n                new NotificationInteractionOptions\n                {\n                    Intent = MessageIntent.Confirmation,\n                    ShowSecondaryButton = true,\n                    ShowDismiss = false,\n                    PrimaryButtonText = \"Destroy\",\n                    SecondaryButtonText = \"Cancel\"\n                },\n                context.CancellationToken).ConfigureAwait(false);\n\n            if (result.Canceled || !result.Data)\n            {\n                context.Logger.LogInformation(\"User canceled the destroy operation.\");\n                throw new OperationCanceledException(\"Destroy operation canceled by user.\");\n            }\n        }\n\n        // Delete the resource group\n        var deleteTask = await context.ReportingStep.CreateTaskAsync(\n            new MarkdownString($\"Deleting resource group **{resourceGroupName}** ({resources.Count} resource(s))\"),\n            context.CancellationToken).ConfigureAwait(false);\n        await using var __ = deleteTask.ConfigureAwait(false);\n\n        try\n        {\n            await resourceGroup.DeleteAsync(WaitUntil.Started, context.CancellationToken).ConfigureAwait(false);\n\n            var portalUrl = AzurePortalUrls.GetResourceGroupUrl(subscriptionId, resourceGroupName, subscription.TenantId);\n            context.Summary.Add(\"🗑️ Resource Group\", new MarkdownString($\"[{resourceGroupName}]({portalUrl})\"));\n            context.Summary.Add(\"🔑 Subscription\", subscriptionId);\n            context.Summary.Add(\"⏳ Status\", new MarkdownString($\"Deletion in progress. Monitor [here]({portalUrl})\"));\n","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure/AzureEnvironmentResource.cs#L335-L371","documentation":"After the interactive confirmation prompt, if the user cancels or declines (result.Canceled or result.Data == false), the controller logs the cancellation and throws OperationCanceledException to abort the destroy pipeline before deleting the resource group.","triggerScenarios":"Answering No / cancelling at the destroy confirmation prompt; sending Ctrl+C during the confirmation interaction.","commonSituations":"Users running aspire destroy interactively and reconsidering; accidentally triggering destroy and aborting at the prompt; automation piping a cancel answer.","solutions":["Answer Yes/confirm at the prompt if you actually want to destroy the resources","Re-run the command and confirm to proceed with deletion","Treat the OperationCanceledException as a benign no-op in scripts and exit gracefully"],"exampleFix":"// before\n// user cancels prompt -> OperationCanceledException\n// after\nif (result.Canceled)\n{\n    Console.WriteLine(\"Destroy canceled; no changes made.\");\n    return;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await DestroyAzureResourcesAsync(...); } catch (OperationCanceledException) { /* user canceled; treat as no-op */ }","preventionTips":["Treat cancellation at destructive prompts as expected and exit gracefully","Decide in advance whether to confirm before launching destroy"],"tags":["azure","destroy","cancellation","user-abort"],"backgroundTag":"operation-canceled-by-user","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}