Repository navigation
{Compute} az vm delete: Raise error when resource not found - #34316
William (william051200) wants to merge 6 commits into
Conversation
To addressTick each item as you address it.
Review detailsIndependent reviewReviewed SHA Test validation
Live failure classification: Uncertain. Evidence is only conclusion Authored tests assert missing-resource errors, exit codes, output and request order, including no-wait/403 paths. Negative recordings contain GET 404s. This is static evidence, not passing execution; no tests were run here. Copilot comment 4438172036 is resolved: Risk assessment43/100 · Medium The Medium rating is driven by public CLI behavior, failure-handling behavior.
Live test — FailedFAIL (exit 1) Selectors: Changed test files runWorkflow run: https://github.com/Azure/issue-sentinel/actions/runs/41575187178 Live-test recordings: 1 regenerated — archived in workflow artifact
Recording filesLast 80 lines of azdev output
Ask the Agent Tick a box to queue an action. Requires write access to this repository.
|
There was a problem hiding this comment.
🟡 Changes recommended
The new preflight GET breaks existing deletion test playback because recordings lack the additional VM response, so affected successful-deletion scenarios need to be re-recorded.
1 open issue
What changed in this PR
Updates az vm delete to check VM existence before deletion, addressing #33794 by returning Azure’s error instead of silently succeeding when the VM or resource group is missing.
Changes:
- Registers a custom delete command with a pre-deletion existence check.
- Adds unit coverage for missing resources, successful deletion, authorization failures, and
--no-wait. - Adds scenario tests and recordings for missing VMs and resource groups.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py |
Adds missing-VM and missing-resource-group scenarios. |
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py |
Tests deletion outcomes, errors, and request ordering. |
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_delete_nonexistent_vm.yaml |
Records the missing-VM response. |
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_delete_nonexistent_resource_group.yaml |
Records the missing-resource-group scenario. |
src/azure-cli/azure/cli/command_modules/vm/operations/vm.py |
Adds the existence check and missing-resource error conversion. |
src/azure-cli/azure/cli/command_modules/vm/commands.py |
Registers the custom VMDelete implementation. |
Review effort: Balanced
| VMShow(cli_ctx=self.cli_ctx)(command_args={ | ||
| "resource_group": str(args.resource_group), | ||
| "vm_name": str(args.name), | ||
| "subscription": self.ctx.subscription_id, | ||
| }) |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Current status: |

🤖 PR Validation — ❌ Action needed
❌AzureCLI-FullTest
Related command
az vm deleteDescription
Resolve #33794
Check whether the VM exists before deletion. If the VM or resource group is missing, show Azure’s original error and exit instead of silently succeeding.
Testing Guide
History Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.