-
Notifications
You must be signed in to change notification settings - Fork 266
fix resource discovery logic from deployments #6356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical bug in resource deletion logic where deployments in separate layers were deleting more resources than intended. The issue was that the code was finding ALL resource groups tagged with azd-env-name instead of only the resource groups associated with the specific deployment being deleted.
The fix migrates the resourceGroupsFromDeployment logic from bicep_provider.go to standard_deployments.go and updates ListSubscriptionDeploymentResources to use deployment-specific resource group discovery instead of tag-based discovery. This restores the correct behavior where only resources directly associated with a deployment are deleted.
Key changes:
- Moved
resourceGroupsToDeletefunction frombicep_provider.gotostandard_deployments.goasresourceGroupsFromDeployment - Updated
ListSubscriptionDeploymentResourcesto use deployment-specific resource discovery instead of environment tag-based discovery - Migrated related unit tests from
bicep_provider_test.gotostandard_deployments_test.go
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cli/azd/pkg/infra/provisioning/bicep/bicep_provider.go |
Removed resourceGroupsToDelete function as it's been moved to a more appropriate location |
cli/azd/pkg/infra/provisioning/bicep/bicep_provider_test.go |
Removed tests for resourceGroupsToDelete and unused sort import |
cli/azd/pkg/azapi/standard_deployments.go |
Added resourceGroupsFromDeployment function and updated ListSubscriptionDeploymentResources to use deployment-specific resource discovery |
cli/azd/pkg/azapi/standard_deployments_test.go |
Added unit tests for resourceGroupsFromDeployment covering both successful and failed deployment scenarios |
cli/azd/pkg/azapi/testdata/failed-subscription-deployment.json |
Added test data file for a failed subscription deployment (currently unused) |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
In #6324, it was discovered that deletion for deployments in separate layers were deleting more resources than intended. Specifically, all resource groups associated with
azd-env-nametag were deleted, rather than resource groups associated with the deployment.To fix this, the logic in
ListSubscriptionDeploymentResourceshas been updated to find resources associated to a deployment. This change effectively restores the behavior prior to 72bc498.As part of this change, the existing logic in
bicep_provider.gowas migrated over.Fixes #6324