# Using Ansible playbook to automate deployment of Azure virtual machines. How to automatically enroll new VMs in Intune?

**URL:** <https://forum.ansible.com/t/using-ansible-playbook-to-automate-deployment-of-azure-virtual-machines-how-to-automatically-enroll-new-vms-in-intune/6367>\
**Category:** Get Help\
**Tags:** azure, playbook, collections, ansible-core\
**Created:** [June 13, 2024, 7:14pm UTC](https://forum.ansible.com/t/using-ansible-playbook-to-automate-deployment-of-azure-virtual-machines-how-to-automatically-enroll-new-vms-in-intune/6367 "2024-06-13T19:14:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterG](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@PeterG](https://forum.ansible.com/u/PeterG)\
**Post date:** [June 13, 2024, 7:14pm UTC](https://forum.ansible.com/t/using-ansible-playbook-to-automate-deployment-of-azure-virtual-machines-how-to-automatically-enroll-new-vms-in-intune/6367/1 "2024-06-13T19:14:59Z")

</div>

Our department has used Ansible playbooks to successfully automate deployment of Azure virtual machines previously. **We have a new use case where we need to adapt existing playbooks to deploy Azure VMs that are Entra ID joined only (not domain joined, not hybrid joined) and automatically enroll those VMs in Intune.**

Would any Ansible experts be able to advise on how we should proceed?

For additional context: I didn’t find references to Intune in [the documentation for Azure.Azcollection](https://docs.ansible.com/ansible/latest/collections/azure/azcollection/index.html). When researching options, I found Terraform code that may be relevant to our use case, but nothing related to Ansible.

Our current theory involves the AADLoginForWindows Azure module and azure.azcollection.azure\_rm\_virtualmachineextension.
