I'm following the documentation to create a container instance in an existing vnet and pass the vnet's ID as the --vnet parameter as follows:
az container create \
--resource-group 123
<...>
--vnet 944xxxxx-xxxx-xxxx-xxxx-xxxxxb0c9b0
But instead, Azure creates a new vnet with the name of if ID that I've passed.
Is it a bug?
Documentation link: https://learn.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az-container-create
--vnet
The name of the VNET when creating a new one or referencing an existing one. Can also reference an existing vnet by ID. This allows using vnets from other resource groups.
Thanks!
When I ran below CLI command including VNet ID, it created container instance inside new VNet with passed ID like below:
az container create \
--name sricontainer \
--resource-group myresourcegroup \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--vnet 5426cefe-5382-44c8-80b9-xxxxxxxx \
--subnet default
Response:
To create Azure container instance in existing VNet, you need to pass ResourceID
of VNet that can be found here:
When I ran the below CLI command by passing ResourceID in --vnet
parameter, it created container instance in existing VNet successfully like this:
az container create \
--name devicontainer \
--resource-group myresourcegroup \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--vnet /subscriptions/b83c1ed3-c5b6-44fb-b5ba-xxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/srivnet \
--subnet default
Response:
In your case, make sure to pass Resource ID of existing VNet in --vnet
parameter.
Reference:
Deploy container group to Azure virtual network - Azure Container Instances | Microsoft