(NetcfgInvalidSubnet)子网 'mySubnet' 在虚拟网络 'myVnet' 中无效

(NetcfgInvalidSubnet) Subnet 'mySubnet' is not valid in virtual network 'myVnet'

我在尝试创建引用现有虚拟网络和子网的 azure 容器实例时遇到一个奇怪的问题。 为此,我正在使用来自 Azure CLI 的 Microsoft 文档 运行 中描述的以下命令:

az 容器创建

--name mycontainer   --resource-group myresourcegroup  --image crazlabjira01.azurecr.io/jira-servicemanagement:4.19.0 --vnet **myVnet** --vnet-address-prefix 172.27.0.0/16 --subnet **mySubnet** --subnet-address-prefix 172.27.14.0/24

我的子网在 Vnet 范围内,为什么命令 returns 出现以下错误:

(NetcfgInvalidSubnet) Subnet 'mySubnet' is not valid in virtual network 'myVnet'

请注意,如果我使用上面定义的 UI 和网络创建该容器,它可以正常工作

感谢帮助

我在我的环境中进行了测试,它对我来说工作正常。

az container create --name myconatainer98044 -g v-ra****-***tr**e --image mycontainer7723.azurecr.io/atlassian/jira-servicemanagement:latest --vnet RG-VNET --vnet-address-prefix 10.0.0.0/16 --subnet TestSubnet --subnet-address-prefix 10.0.1.0/24

创建虚拟网络时,您可以配置地址 space。默认情况下,我的地址 space 为 10.0.0.0/16,它允许从 10.0.0.0 到 10.0.255.255 的地址。

通过将子网更改为 10.0.0.0/16 地址的有效值 space,例如 10.0.1.0/24,您可能会成功:

为您确保您尝试使用的子网未被其他资源提供者使用。在这里,您可能正在尝试使用已在使用中的 172.27.14.0/24 子网。

Example : If you using a subnet for creating a SQL instance and the same subnet you are using for creating the Container Instance it will throw an error which you are getting. So Microsoft doesn’t support the same subnet to create a different resource provider.

在我的案例中,我的 TestSubnet 被委托给 Microsoft.Containerintance

请参阅此document以获得清晰的理解。