Azure / Azure/azure-cli

az vm delete Command Does Not Return an Error When the Specified Resource Group or Virtual Machine Does Not Exist

Open
#33,794 3 comments 1 reaction 3 assignees Claimed by @a0x1ab View on GitHub
act-observability-squad Auto-Assign Auto-Resolve Azure CLI Team bug Compute customer-reported
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

When executing the az vm delete command with a non-existent virtual machine name and/or resource group, the command completes successfully without returning an error, warning, or non-zero exit code. This behaviour may mislead users and automation workflows into assuming that the deletion operation was successful, even though the target resource was never present.

### Related command

az vm delete --resource-group pav -n pavithra

### Errors

It does not return any error

### Issue script & Debug output

pavithra [ ~ ]$ az vm delete --resource-group pav -n pavithra --debug
cli.knack.cli: Command arguments: ['vm', 'delete', '--resource-group', 'pav', '-n', 'pavithra', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Using packaged command index for profile 'latest'.
cli.azure.cli.core: Found installed extension 'ml' (azext_mlv2).
cli.azure.cli.core: Blending packaged core index with local extension index.
cli.azure.cli.core: Modules found from index for 'vm': ['azure.cli.command_modules.vm']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Loaded command modules in parallel:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: vm 0.300 61 224
cli.azure.cli.core: Total (1) 0.303 61 224
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 61 groups, 224 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : vm delete
cli.azure.cli.core: Command table: vm delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/pavithra/.azure/commands/2026-07-27.06-38-58.vm_delete.1308.log'.
az_command_data_logger: command args: vm delete --resource-group {} -n {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7ff78434af20>]
cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 437, in _get_attr
op = import_module(full_mod_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1310, in _find_and_load_unlocked
File "", line 488, in _call_with_frames_removed
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.mgmt.compute.v2024_03_03'

cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7ff78434ba60>, .add_global_policy_argument at 0x7ff78434bba0>, .add_cache_arguments at 0x7ff78434bc40>, .update_breaking_change_info at 0x7ff78434bce0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7ff78434bb00>]
Are you sure you want to perform this operation? (y/n): y
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
urllib3.connectionpool: Starting new HTTPS connection (1): login.microsoftonline.com:443
urllib3.connectionpool: https://login.microsoftonline.com:443 "GET /common//v2.0/.well-known/openid-configuration HTTP/1.1" 200 1728
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_credentials: CloudShellCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], kwargs={}
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 3236
msal.token_cache: event={
"authority_type": "CLOUDSHELL",
"client_id": "04b07795-8ddb-461a-bbee-02f9e1bf7b46",
"data": {},
"response": {
"access_token": "********",
"client_info": "eyJ1aWQiOiAiZWUzYTM2ZTYtYjdhMy00MzMzLTlhOTYtYTE5ZjQwNTdkNGY1IiwgInV0aWQiOiAiMTZiM2MwMTMtZDMwMC00NjhkLWFjNjQtN2VkYTA4MjBiNmQzIn0=",
"expires_in": 3518,
"id_token_claims": "********",
"token_type": "Bearer"
},
"scope": [
"https://management.core.windows.net//.default"
],
"token_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token"
}
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/eb5cca67-d660-477a-ac9a-12de78532a35/resourceGroups/pav/providers/Microsoft.Compute/virtualMachines/pavithra?api-version=2024-11-01'
cli.azure.cli.core.sdk.policies: Request method: 'DELETE'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'd8a30a4a-8985-11f1-926c-00155dd9c586'
cli.azure.cli.core.sdk.policies: 'CommandName': 'vm delete'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--resource-group -n --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.87.0 (RPM) azsdk-python-core/1.39.0 Python/3.12.9 (Linux-6.1.146.1-microsoft-standard-x86_64-with-glibc2.38) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "DELETE /subscriptions/eb5cca67-d660-477a-ac9a-12de78532a35/resourceGroups/pav/providers/Microsoft.Compute/virtualMachines/pavithra?api-version=2024-11-01 HTTP/1.1" 204 0
cli.azure.cli.core.sdk.policies: Response status: 204
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-deletes': '199'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-deletes': '2999'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '6ab7fe7f-34de-48ef-9f23-e1bcdf8f57d9'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '6ab7fe7f-34de-48ef-9f23-e1bcdf8f57d9'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'EASTUS2:20260727T063901Z:6ab7fe7f-34de-48ef-9f23-e1bcdf8f57d9'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: 1A4D99E3073B4AE19FDF10C963DC4D5E Ref B: SG2AA1070301060 Ref C: 2026-07-27T06:39:01Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Mon, 27 Jul 2026 06:39:00 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies:
cli.knack.cli: Event: CommandInvoker.OnTransformResult [, ]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 3.447 seconds (init: 0.071, invoke: 3.376)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 4182 in cache file under /home/pavithra/.azure/telemetry/20260727063901736
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.12 /usr/lib/az/lib/python3.12/site-packages/azure/cli/telemetry/__init__.py /home/pavithra/.azure /home/pavithra/.azure/telemetry/20260727063901736"
telemetry.process: Return from creating process 1321
telemetry.main: Finish creating telemetry upload process.
pavithra [ ~ ]$

### Expected behavior

CLI should return an error stating RG or VM name not found under the subscription

### Environment Summary

pavithra [ ~ ]$ az --version
azure-cli 2.87.0 *

core 2.87.0 *
telemetry 1.1.0

Extensions:
ml 2.43.0
ssh 2.0.9

Dependencies:
msal 1.36.0
azure-mgmt-resource 24.0.0

Python location '/usr/bin/python3.12'
Config directory '/home/pavithra/.azure'
Extensions directory '/home/pavithra/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.12/site-packages/azure-cli-extensions'

Python (Linux) 3.12.9 (main, Jun 2 2026, 15:06:48) [GCC 13.2.0]

Legal docs and information: aka.ms/AzureCliLegal

You have 2 update(s) available. They will be updated with the next build of Cloud Shell.
pavithra [ ~ ]$

### Additional context

This behaviour is observed in version 2.87.0, 2.88 but the same command returns expected error on CLI version 2.67

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.