azureazure-container-instances

How to deploy Azure Container Instance to VNET using Azure CLI


I need to deploy Azure Container Instance with VNet connection using Azure CLI. Here's the command I'm using:

az container create -g My_RG --name ubuntu-aci-2 --image ubuntu --vnet /subscriptions/f2ees954-606e-4480-b05f-48c85c8c05cf/resourceGroups/My_RG/providers/Microsoft.Network/virtualNetworks/aci-vnet --subnet default

I'm getting the following error:

Resource /subscriptions/f2ees954-606e-4480-b05f-48c85c8c05cf/resourceGroups/My_RG/providers/Microsoft.Network/virtualNetworks/ACI-VNET referenced by resource /subscriptions/f2ees954-606e-4480-b05f-48c85c8c05cf/resourceGroups/My_RG/providers/Microsoft.Network/networkProfiles/aci-network-profile-aci-vnet-default was not found. Please make sure that the referenced resource exists, and that both resources are in the same region

What am I doing wrong?

// EDIT

The VNET "aci-vnet" and its subdomain "default" already exist before creating the container.


Solution

  • You should deploy the container instance in the region that is the same as the Vnet in the region.