Skip to content

Support delete option for NICs and Disks for VMs in Azure CLI #17846

@szimmer-dev

Description

@szimmer-dev

Resource Provider
CRP

Description of Feature or Work Requested
User experience:

image

In text:

az vm create
-n MyVm
-g MyResourceGroup
--public-ip-address-dns-name MyUniqueDnsName
--image ubuntults
--size Standard_DS2_v2
--generate-ssh-keys
--data-disk-sizes-gb 10 20
--data-disk-delete-option 0=Detach 1=Delete /*Use a singular value to apply on all data disks, or use = to configure the delete behavior for individual disks
--os-disk-delete-option Delete
--nic-delete-option = /*Use a singular value to apply on all nics, or use = to configure the delete behavior for individual NICs

The new switches do the following
--nic-delete-behavior configures the deleteOption field for the NIC created for the VM
vm.properties.networkProfile.networkInterfaces[0].properties.deleteOption = "Delete"

--os-disk-delete-option Delete configures delete option for the OS Disk
cstorageProfile.dataDisks[*].osDisk= "Delete"

--data-disk-delete-option configures the delete option for data disks as specified
vm.properties.storageProfile.dataDisks[*].deleteOption = "Delete"

Swagger PR containing the deleteOption for VM NICs: Azure/azure-rest-api-specs#13449

Swagger PR for disk deleteOption: Azure/azure-rest-api-specs#13657

Minimum API Version Required
2021-03-01

Swagger Link

Target Date
5/25

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions