Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

Description

Implements a pipeline step for Azure environments that deletes the associated resource group after user confirmation via IInteractionService. Addresses the need for a consistent way to tear down Azure test environments.

Key changes:

  • Pipeline step: Added deprovision-{Name} step tagged with "azure-deprovision", depends on provisioning context creation
  • Resource group deletion: Extended IResourceGroupResource interface with DeleteAsync(WaitUntil, CancellationToken), implemented in DefaultResourceGroupResource to wrap Azure SDK's ResourceGroupResource.DeleteAsync
  • Safety: Validates interaction service availability, resource group name, and provisioning context before prompting. User must explicitly confirm deletion with warning dialog showing resource group name
  • Error handling: Reports failures through pipeline step reporting, logs at appropriate levels

Usage:

# Invoked via pipeline step name
aspire do deprovision-azure12345

User sees confirmation dialog:

Title: "Confirm Deprovision"
Message: "Are you sure you want to delete the entire resource group 'my-rg'? 
          This action cannot be undone and will delete all resources in the group."
[Delete Resource Group] [Cancel]

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepjcSpRu/teststorage.module.bicep --stdout -l PipelineStep tion.Tests/AspireKeycloakExtensionTests.cs /home/REDACTED/work/aspire/aspire/.dotnet//grep PipelineStep sts.cs rep grep -l PipelineStep ests/ConnectionP-d nfig/composer/ve168.63.129.16 PipelineStep rver.Tests/Worka-15 /home/REDACTED/wor--destination-port grep (dns block)
    • Triggering command: /usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepZjSyAb/env-acr.module.bicep --stdout -l PipelineStep tion.Tests/AspireKeycloakExtensionTests.cs .dotnet//grep PipelineStep sts.cs /home/REDACTED/.ca-t grep -l PipelineStep ests/ConnectionP-d p/bin/grep PipelineStep rver.Tests/Worka/home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.101/MSBuild.dll .dotnet//grep grep (dns block)
    • Triggering command: /usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepCkSqKf/env.module.bicep --stdout -l PipelineStep Tests/ConnectionPropertiesTests.cs p/bin/grep PipelineStep epositoryTests.c--norc .dotnet//grep grep -l PipelineStep hboard.Tests/ResourceOutgoingPeerResolverTests.cs rgo/bin/grep PipelineStep nectorExtensions/home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.101/MSBuild.dll p/bin/grep grep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add aspire do cleanup command for Azure (and unify cleanup semantics across environments)</issue_title>
<issue_description>Developers need a simple, consistent way to fully tear down test environments—whether deployed to Azure or spun up via Docker Compose. The CLI should offer a one-shot cleanup command with optional finer-grained control, using the same mental model across environments.

Goals

  • Introduce aspire do cleanup, which should:
    • Detect the resource group associated with the current deployment.
    • Delete (“nuke”) the entire resource group in one operation.
  • Explore whether more granular cleanup commands are needed, e.g.:
    • aspire do cleanup-storage
    • aspire do cleanup-cosmosdb
  • Align this feature with the existing Docker Compose flow:
    • Unify command semantics with aspire do docker-compose-down-env, so cleanup behavior feels consistent across Azure and local container environments.

Open Questions

  • How do we surface safety checks, confirmation prompts, or dry-runs for destructive operations?
  • Should we implement some sort of tagging primitive to mark certain resources as never removable?
    </issue_description>

<agent_instructions>Add a deprovision step that is on the Azure environment resource that will remove the deployment that was issued by clearing everything that is in the resource group. Use the interaction service to prompt the user for confirmation before initializing the resource group deletion request.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@davidfowl Lets start with a top level command with a single confirmation prompt implemented in docker compose and azure, that tears down the environment.
aspire up <-> aspire down
aspire destroy 
aspire undeploy  // kind ugly but symmetrical

I'm not sure how I feel about cleanup the name...</comment_new>
<comment_new>@captainsafia
I think it's better to start off with a step and then elevate it to a a top-level command. We lose some value in discoverability, but it gives us air cover to iterate.

Also, we can create steps with more specific verbs like deprovision for Azure as opposed to having to try to find the one verb to rule them all.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 15, 2025 20:27
- Added deprovision pipeline step to AzureEnvironmentResource with "azure-deprovision" tag
- Step prompts for confirmation using IInteractionService before deletion
- Implemented DeleteAsync method on IResourceGroupResource interface
- Added test to verify deprovision step is created correctly
- Updated test helpers to support new DeleteAsync operation

Co-authored-by: captainsafia <[email protected]>
- Add dependency configuration: deprovision step now depends on create context step
- Add provisioning context validation: check if task is completed before attempting deletion
- Simplify deletion: use WaitUntil.Completed instead of Started + WaitForCompletion
- Remove redundant logging about "waiting for completion" since we wait inline now

Co-authored-by: captainsafia <[email protected]>
Copilot AI changed the title [WIP] Add aspire do cleanup command for Azure and unify semantics Add Azure environment deprovision step for resource group deletion Dec 15, 2025
Copilot AI requested a review from captainsafia December 15, 2025 20:38
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13570

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13570"

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.

Add aspire do cleanup command for Azure (and unify cleanup semantics across environments)

2 participants