简体   繁体   English

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

[英]Azure creating VM on existing VNET with multiple subnets

I have multiple VMs already in the same VNET. 我在同一VNET中已经有多个VM。 When I create a new VM trying to use that same VNET I get an error. 创建新的VM尝试使用相同的VNET时,出现错误。 I do not want to delete existing subnets (4) already in the vnet. 我不想删除vnet中已经存在的现有子网(4)。 All I want to do is add a new vm to the already existing vnet with a new subnet attached to it. 我要做的就是将一个新的vm添加到已存在的vnet中,并附加一个新的子网。 I have seen similar posts but none show how to deal with multiple existing subnets. 我看到过类似的帖子,但都没有显示如何处理多个现有子网。

This is the error 这是错误

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.

here is how I am creating a new vm. 这是我创建新虚拟机的方法。

'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'

What is happening - az vm create is attempting to perform a create vnet with this subnet only (so overwrite your existing vnet configuration). 发生了什么az vm create尝试仅使用此子网执行创建vnet(因此覆盖现有的vnet配置)。 Nothing you can really do about this, what you can do is precreate the subnet in the vnet , after that your command will work. 您对此无能为力,可以做的是在vnet中预先创建子网 ,然后命令将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM