Ansible - Azure resource referencing
With a bit trial and error I was able to work out the values for my &quot;vnet_id&quot; and &quot;snet_id&quot; variables.
I found using the full ID for the virtual network and not having a &quot;/&quot; before the subnet variable (snet_id) value fixed my problem.
At the moment I don't fully understand how Ansible/Azure puts it all together, but this has given me enough information to start to understand.
If anyone could point me to some documentation that explains the construction/interpolation of the variables it would be helpful.
  tasks:
   - set_fact:
       vnet_rg_id: &quot;/subscriptions/REVMOVED-SUB-ID/resourceGroups/rg-ansible-test&quot;
       vnet_id: &quot;/subscriptions/REVMOVED-SUB-ID/resourceGroups/rg-ansible-test/providers/Microsoft.Network/virtualNetworks/vnet-ansible-test&quot;
       snet_id: &quot;snet-ansible-test&quot;

   - name: Create resource group
     azure_rm_resourcegroup:
       name: &quot;{{ rg }}&quot; # declared earlier in the playbook
       location: &quot;{{ location }}&quot; # declared earlier in the playbook

   - name: Create virtual network inteface cards for VM
     azure_rm_networkinterface:
       resource_group: &quot;{{ rg }}&quot; # declared earlier in the playbook
       name: &quot;{{ nic_name }}&quot; # declared earlier in the playbook
       virtual_network: &quot;{{ vnet_id }}&quot;
       subnet: &quot;{{ snet_id }}&quot;
       location: &quot;{{ location }}&quot; # declared earlier in the playbook