# How to specify a virtual network in a different resource group when creating a new Azure VM?

**URL:** <https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [January 13, 2017, 2:09am UTC](https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446 "2017-01-13T02:09:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Ngan](https://avatars.discourse-cdn.com/v4/letter/v/58956e/32.png) [@Vincent\_Ngan](https://forum.ansible.com/u/Vincent_Ngan)\
**Post date:** [January 13, 2017, 2:09am UTC](https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446/1 "2017-01-13T02:09:18Z")

</div>

Hi,

I am trying to create a VM in Azure using Ansible. The setup of our Azure configuration is that the virtual network is created in a different resource manager from the virtual machines’. When I using azure\_rm\_virtualmachine module to create a virtual machine in Azure, the module complains that the virtual network does not exist in the resource manager of the virtual machine to be created. Is there any way I can do that? Can I specify a virtual network with a fully qualified name including its resource manager name so that the module would not confuse it with the resource manager of the virtual machine?

Vincent

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [January 13, 2017, 8:21pm UTC](https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446/2 "2017-01-13T20:21:43Z")

</div>

I know I tested this back when we first wrote it, so unless it got broken along the way somewhere, if you pass the full resource URI for the vnet (regardless of whether or not it’s in the same RG), it should do the right thing…

---

<div class="post-metadata">

**Author:** ![Bamar\_Diagne](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Bamar\_Diagne](https://forum.ansible.com/u/Bamar_Diagne)\
**Post date:** [February 14, 2017, 11:47am UTC](https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446/3 "2017-02-14T11:47:22Z")

</div>

Hi,

I am facing the same issue, did you manage to get down to the bottom of this. I am having no luck so far.

Cheers  
Bamar

---

<div class="post-metadata">

**Author:** ![shanmuga\_Mahalingam](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@shanmuga\_Mahalingam](https://forum.ansible.com/u/shanmuga_Mahalingam)\
**Post date:** [February 15, 2017, 2:49pm UTC](https://forum.ansible.com/t/how-to-specify-a-virtual-network-in-a-different-resource-group-when-creating-a-new-azure-vm/23446/4 "2017-02-15T14:49:29Z")

</div>

I tried with full URI and no luck.

virtual\_network\_name: /subscriptions/\<Subscriptions\_ID\>/resourceGroups/\<Resource\_Group\>/providers/Microsoft.Network/virtualNetworks/ansible\_test

Anyone help on this pls ?
