I'm working on an Azure CLI script to automate the creation of a vnet in our cloud infrastructure. One of the parts in this script is linking a VNET to a Azure Private DNS. This should be easy, but apperently the difficulty is the fact that the VNET and the Private DNS are in a different resourcegroup.
This is my script;
az network private-dns link vnet create --name MyLink \
--registration-enabled true \
--resource-group my-vnet-resourcegroup\
--subscription 'My Subscription' \
--tags Domain=MyDomain \
--virtual-network my-own-vnet \
--zone-name myzone.nu
Now when exuting i'm getting the following error;
Can not perform requested operation on nested resource. Parent resource 'myzone.nu' not found.
So I updated the script to look at the resourcegroup for the private DNS;
az network private-dns link vnet create --name MyLink \
--registration-enabled true \
--resource-group my-privatedns-resourcegroup \
--subscription 'My Subscription' \
--tags Domain=MyDomain \
--virtual-network my-own-vnet \
--zone-name myzone.nu
This gives me the following error;
Deployment failed. Correlation ID: (SomeGuid). Virtual network resource not found for '/subscriptions//resourceGroups/my-privatedns-resourcegroup/providers/Microsoft.Network/virtualNetworks/my-own-vnet'
I'm quite stuck at the moment on how to fix this. Anybody else ran into this before? I'm open to suggestions!