Subnet 'Subnet-1' is not valid in virtual network 'XYZabc'

Category: azure scripting and command line tools

Question

yup. _ on Wed, 20 Jun 2018 10:55:30


My current deployments fail with this syntax;

az vm create -n MyVm2 -g "ilbtest" --public-ip-address "" --image win2016datacenter  --admin-username "adminBOSS" --admin-password "taratara12345#" --vnet-name XYZabc --subnet "Subnet-1" --subnet-address-prefix a.b.c.d/27

Citing Subnet 'Subnet-1' is not valid in virtual network 'XYZabc'

Now, these are different resource groups for (1) Hosts the VNet (2) Used for deployments. How can I refer one from another?


yup

Replies

CHEEKATLAPRADEEP-MSFT on Wed, 20 Jun 2018 11:29:45


Note: The VNet should exist in the same resource group because all the resources in your group should share the same lifecycle.

For more details, refer “Resource groups” and “az vm create”.

-----------------------------------------------------------------------------------------------

If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

yup. _ on Wed, 20 Jun 2018 11:38:55


That's incorrect for I've numerous Portal based deployments working in that way.

YASWANTHM-MSFT on Wed, 20 Jun 2018 19:51:46


I would recommend you to try the following script and see if it helps you.

az vm create --name MyVm2 --resource-group yashcli --image win2016datacenter --admin-username XXX --admin-password XXXXX --vnet-name myVMVNET --subnet yashsub

you will get a output as shown below.

----------------------------------------------------------------------------------------------

If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click here.

yup. _ on Thu, 21 Jun 2018 04:56:13


Hey guys the problem was sort of typo where in the resolution was to replace "Subnet-1" with Subnet-1.

CHEEKATLAPRADEEP-MSFT on Thu, 21 Jun 2018 05:23:35


Glad to hear that your issue is resolved. Appreciate for sharing the information which helped you, this would certainly benefit other community members.