Azure / Azure/azure-cli

Deleting VM with 'az vm delete' does not delete its disk

Open
#4,897 28 comments 8 reactions 1 assignee Claimed by @qwordy View on GitHub
act-observability-squad Compute customer-reported feature-request Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

If I delete a VM with _az vm delete_ I expect all dependent resources to be deleted too. But disks are not.

E.g. I have VM _tw-001-westeurope_

```
kristian@opossum:~$ az vm show -n tw-001-westeurope -g tw-rg-westeurope
{
"availabilitySet": null,
"diagnosticsProfile": null,
"hardwareProfile": {
"vmSize": "Basic_A1"
},
"id": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Compute/virtualMachines/tw-001-westeurope",
"identity": null,
"instanceView": null,
"licenseType": null,
"location": "westeurope",
"name": "tw-001-westeurope",
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Network/networkInterfaces/tw-001-westeuropeVMNic",
"primary": null,
"resourceGroup": "tw-rg-westeurope"
}
]
},
"osProfile": {
"adminPassword": null,
"adminUsername": "azureuser",
"computerName": "tw-001-westeurope",
"customData": null,
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"keyData": "***",
"path": "/home/azureuser/.ssh/authorized_keys"
}
]
}
},
"secrets": [],
"windowsConfiguration": null
},
"plan": null,
"provisioningState": "Succeeded",
"resourceGroup": "tw-rg-westeurope",
"resources": null,
"storageProfile": {
"dataDisks": [],
"imageReference": {
"id": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Compute/images/tw-image-2017-11-13",
"offer": null,
"publisher": null,
"resourceGroup": "tw-rg-westeurope",
"sku": null,
"version": null
},
"osDisk": {
"caching": "None",
"createOption": "FromImage",
"diskSizeGb": 30,
"encryptionSettings": null,
"image": null,
"managedDisk": {
"id": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Compute/disks/tw-001-westeurope",
"resourceGroup": "tw-rg-westeurope",
"storageAccountType": "Standard_LRS"
},
"name": "tw-001-westeurope",
"osType": "Linux",
"vhd": null
}
},
"tags": {},
"type": "Microsoft.Compute/virtualMachines",
"vmId": "abdaa320-2fef-4c22-aca1-339682f21bfd",
"zones": null
}
```

and delete it with _az vm delete_:

```
kristian@opossum:~$ az vm delete -g tw-rg-westeurope -n tw-001-westeurope --yes
{
"endTime": "2017-11-16T13:48:11.344229+00:00",
"error": null,
"name": "6a7b12f7-779d-4014-9794-720feb670f0f",
"startTime": "2017-11-16T13:47:09.907105+00:00",
"status": "Succeeded"
}
```

the disk that was attached to the VM is still there:

```
kristian@opossum:~$ az disk show -n tw-001-westeurope -g tw-rg-westeurope
{
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Compute/snapshots/tw-image-2017-11-13_envfb1jz4qg",
"sourceUri": null,
"storageAccountId": null
},
"diskSizeGb": 30,
"encryptionSettings": null,
"id": "/subscriptions/***/resourceGroups/tw-rg-westeurope/providers/Microsoft.Compute/disks/tw-001-westeurope",
"location": "westeurope",
"managedBy": null,
"name": "tw-001-westeurope",
"osType": "Linux",
"provisioningState": "Succeeded",
"resourceGroup": "tw-rg-westeurope",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"tags": {},
"timeCreated": "2017-11-16T12:28:51.081460+00:00",
"type": "Microsoft.Compute/disks",
"zones": null
}
```

---

### Environment summary

Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (`az --version`) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)

```
azure-cli (2.0.20)

acr (2.0.14)
acs (2.0.18)
appservice (0.1.19)
backup (1.0.2)
batch (3.1.6)
batchai (0.1.2)
billing (0.1.6)
cdn (0.0.10)
cloud (2.0.9)
cognitiveservices (0.1.9)
command-modules-nspkg (2.0.1)
component (2.0.8)
configure (2.0.12)
consumption (0.1.6)
container (0.1.12)
core (2.0.20)
cosmosdb (0.1.14)
dla (0.0.13)
dls (0.0.16)
eventgrid (0.1.5)
extension (0.0.5)
feedback (2.0.6)
find (0.2.7)
interactive (0.3.11)
iot (0.1.13)
keyvault (2.0.13)
lab (0.0.12)
monitor (0.0.11)
network (2.0.17)
nspkg (3.0.1)
profile (2.0.15)
rdbms (0.0.8)
redis (0.2.10)
resource (2.0.17)
role (2.0.14)
servicefabric (0.0.5)
sql (2.0.14)
storage (2.0.18)
vm (2.0.17)

Python location '/opt/az/bin/python3'
Extensions directory '/home/kristian/.azure/cliextensions'

Python (Linux) 3.6.1 (default, Oct 18 2017, 20:41:18)
[GCC 4.8.4]

```

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.