Deleting VM with 'az vm delete' does not delete its disk
See original GitHub issueIf 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]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:28 (15 by maintainers)
Top Results From Across the Web
Delete a VM and attached resources - Azure Virtual Machines
Under Disk options, by default the OS disk is set to Delete with VM. If you don't want to delete the OS disk,...
Read more >Azure – You can now request to delete associated resources ...
As you know after deleting a virtual machine on Azure you need to delete the depend resources – virtual disk, network interface…
Read more >Delete Azure VM and all associated Resources using ...
Following PowerShell Script will help you to delete the Virtual Machine and all the associated resources like Disks (Boot Diagnostics Disk, OS, Data...
Read more >Delete a VM | Compute Engine Documentation | Google Cloud
Delete an instance to remove the instance and the associated resources from your project. If the instance is part of an instance group,...
Read more >How To Remove An Azure Virtual Machine (VM)
How To Delete A VM In Azure ... Search for Virtual machines there. ... You will see the list of VM created in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure. I’ll look into it after holiday (1st Oct ~ 7th Oct).
As a new user of the az CLI, the number of disks I just found after iterating on a
vm create; test; vm delete
cycle was extremely surprising! Please implement something to help in this space! 😃