Azure在具有多个子网的现有VNET上创建VM

时间:2019-07-25 17:17:29

标签: azure azure-virtual-machine azure-virtual-network

我在同一VNET中已经有多个VM。创建新的VM尝试使用相同的VNET时,出现错误。我不想删除vnet中已经存在的现有子网(4)。我要做的就是将一个新的vm添加到已存在的vnet中,并附加一个新的子网。我看到过类似的帖子,但都没有显示如何处理多个现有子网。

这是错误

Subnet Foo2Subnet is in use by /subscriptions/<subid>/resourceGroups/foo-westus2/providers/Microsoft.Network/networkInterfaces/Foo2VMNic/ipConfigurations/Foo2 
 cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

这是我创建新虚拟机的方法。

'az vm create ' \
    '--resource-group {resourceGroupName} ' \
    '--name  "{serverName}" ' \
    '--image "UbuntuLTS" ' \
    '--use-unmanaged-disk ' \
    '--vnet-name foo2VNET ' \
    '--subnet test1' \
    '--public-ip-address "" ' \
    '--storage-sku Standard_LRS ' \
    '--admin-username {user_name} ' \
    '--admin-password "{password}" ' \
    '--size "{vm_size}" ' \
    '--custom-data  "" --no-wait'

1 个答案:

答案 0 :(得分:1)

正在发生的事情-az vm create尝试仅使用此子网执行创建vnet(因此覆盖现有的vnet配置)。您对此无能为力,您只能执行precreate the subnet in the vnet,此后您的命令将起作用。