Skip to content

az vm create - option "--subnet" having incorrect behavior #10728

@oneoneonepig

Description

@oneoneonepig

Describe the bug

Command Name
az vm create

Errors:
Unable to delete the subnet 'Default' because the subnet is in used

To Reproduce:

  • Multiple VM instances are created with the same vnet "MyRG-vnet" and subnet "Default" within it
  • Only a single vnet and a single subnet exist in the resource group
  • az vm create -n MyRG --image Win2019Datacenter --size Standard_D2s_v3 --nsg sql-server --vnet-name MyRG-vnet

Expected Behavior

The VM should be created since the option "--subnet" is not required to be provided. Mentions in the documents, --subnet The name of the subnet when creating a new VNet or referencing an existing one. Can also reference an existing subnet by ID. If omitted, an appropriate VNet and subnet will be selected automatically, or a new one will be created. Which means, if the option "--subnet" is not provided, it will select the one and only subnet "Default" in my vnet. It did not select the subnet, instead seems like it tried to delete the subnet "Default" and attempted to create a new one (probably with the same name)

After I manually added the option "--subnet Default", it works, but the behavior contradicts with the description in the command reference.

Environment Summary

Linux-4.15.0-1059-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Shell: bash

azure-cli 2.0.74

Extensions:
aks-preview 0.4.8

Metadata

Metadata

Assignees

Labels

Computeaz vm/vmss/image/disk/snapshot

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions