1

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.

0

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

3 Comments

I don't think this is the case. I am able to successfully deploy the container when using the Azure Portal (with the same settings).
Could you double-check? On the Azure portal, I only could select the VNet in the region which is the same as the region where the container instance will deploy.
Ha, looks like you were right. The thing I missed was the "--location". It looks like by default it was deploying to US East, which a different region that my VNET.
0

The subnet you deploy to should also not have any other resources assigned to the same subnet or the deployment will fail.

Microsoft guide: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-vnet#deploy-to-existing-virtual-network

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.