There are many reasons why you may need to duplicate an existing virtual network, and, of course, the reasons will vary. In my case, my customer asked to create a “bubble” network where they want to replicate the same layout and IP ranges associated. I went ahead and created a script to do exactly that, making sure that all IP ranges for the virtual network and subnets are replicated to a second virtual network. The script for cloning an Azure virtual network is simple, and you can get access to the source here. We need to provide the virtual network that we want to clone, the destination resource group and a name for the clone. (This name will be added as a suffix of the cloned virtual network.)
The result will be a brand new virtual network with the configuration at the IP level of the original virtual network.
So, as you can see, cloning an Azure virtual network is a snap.
hi, do you have any idea why I would get the following output?
VNETClone.ps1: Cannot validate argument on parameter ‘SourceVirtualNetworkName’. The “Get-AzVirtualNetwork -Name ($_)” validation script for the argument with value “prod-vnet” did not return a result of True. Determine why the validation script failed, and then try the command again.
does this script only work when cloning from within the same subscription?