# azure\_rm\_deployment failing

**URL:** <https://forum.ansible.com/t/azure-rm-deployment-failing/27845>\
**Category:** Ansible Developer\
**Tags:** azure\
**Created:** [June 21, 2018, 10:01pm UTC](https://forum.ansible.com/t/azure-rm-deployment-failing/27845 "2018-06-21T22:01:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tannerjonj](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjonj/32/398_2.png) [@tannerjonj](https://forum.ansible.com/u/tannerjonj)\
**Post date:** [June 21, 2018, 10:01pm UTC](https://forum.ansible.com/t/azure-rm-deployment-failing/27845/1 "2018-06-21T22:01:32Z")

</div>

Using Ansible to deploy VMs to Azure using the azure\_rm\_deployment module. The deployment in Azure works but I get the following errors back in Ansible

TASK [Hedberg\_deploy\_template : Execute Azure Deployment] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Thursday 21 June 2018 19:51:16 +0000 (0:00:00.745) 0:00:00.936 \*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“rc”: 1  
}

MSG:

MODULE FAILURE

MODULE\_STDERR:

No handlers could be found for logger “msrestazure.azure\_active\_directory”  
Traceback (most recent call last):  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 664, in   
main()  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 660, in main  
AzureRMDeploymentManager()  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 434, in **init**  
supports\_check\_mode=False)  
File “/tmp/ansible\_JHtP7p/ansible\_modlib.zip/ansible/module\_utils/azure\_rm\_common.py”, line 345, in **init**  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 457, in exec\_module  
instances=self.\_get\_instances(deployment)  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 609, in \_get\_instances  
for vm, nics in vms\_and\_nics]  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 653, in \_nic\_to\_public\_ips\_instance  
nic[‘dep’].resource\_name) for nic in nics)  
File “/tmp/ansible\_JHtP7p/ansible\_module\_azure\_rm\_deployment.py”, line 653, in   
nic[‘dep’].resource\_name) for nic in nics)  
File “/tmp/ansible\_JHtP7p/ansible\_modlib.zip/ansible/module\_utils/azure\_rm\_common.py”, line 889, in network\_client  
File “/tmp/ansible\_JHtP7p/ansible\_modlib.zip/ansible/module\_utils/azure\_rm\_common.py”, line 843, in get\_mgmt\_svc\_client  
File “/usr/lib/python2.7/site-packages/azure/mgmt/network/network\_management\_client.py”, line 98, in **init**  
profile=profile  
File “/usr/lib/python2.7/site-packages/azure/profiles/multiapiclient.py”, line 47, in **init**  
raise ValueError(“Cannot use api-version and profile parameters at the same time”)  
ValueError: Cannot use api-version and profile parameters at the same time

The Ansible role that is failing is as follows:

- name: Create a unique string to be used as a Azure deployment id

shell: echo “`date +"%Y%m%d%H%M%S"`-$(cat /dev/urandom | tr -cd [:alpha:] | tr ‘[:upper:]’ ‘[:lower:]’ | head -c 8)”

register: deployment\_id

- name: Execute Azure Deployment

azure\_rm\_deployment:

ad\_user: “{{ authprofile[inventory\_target].azure\_ad\_user }}”

password: “{{ authprofile[inventory\_target].azure\_password }}”

subscription\_id: “{{ authprofile[inventory\_target].azure\_subscription\_id }}”

state: present

deployment\_mode: incremental

deployment\_name: “{{ deployment\_id.stdout }}”

location: “{{ location }}”

resource\_group\_name: “{{ resourcegroupname }}”

template: “{{ lookup(‘file’, ‘{{ template\_file\_name }}’) }}”

parameters:

“{{ ARMtemplateprofile[ARM\_profile] }}”

register: azureout"

My Ansible version is …

ansible --version  
ansible 2.5.5  
config file = None  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 2.7.14 (default, Feb 22 2018, 22:26:54) [GCC 5.3.0]

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 25, 2018, 9:55am UTC](https://forum.ansible.com/t/azure-rm-deployment-failing/27845/2 "2018-06-25T09:55:15Z")

</div>

Given the error message, “Cannot use api-version and profile parameters at the same time”, my guess its there is something unexpected about the contents of your

`parameters: "{{ ARMtemplateprofile[ARM_profile] }}"`

I suggest maybe using `debug` module on that to make sure it contains what you expect. Add a task in to your playbook something like this:

`

- name: show profile  
debug:  
var: “{{ ARMtemplateprofile[ARM\_profile] }}”

`

Hope this helps,

Jon
