title: Ansible: How to use an Azure RM template in `azure_rm_deployment` module?
body: <p>I have a virtual machine ARM template built in the following way: <sup><a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-ps-template/" rel="nofollow">refernce</a></sup></p>
  
  <pre><code>{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {  },
    "variables": {  },
    "resources": [  ],
    "outputs": {  }
  }
  </code></pre>
  
  <p>with <code>parameters.json</code>:</p>
  
  <pre><code>{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "adminUserName": { "value": "mytestacct1" },
      "adminPassword": { "value": "mytestpass1" }
    }
  }
  </code></pre>
  
  <p>I can successfully deploy the machine using this template in PowerShell:</p>
  
  <pre><code>New-AzureRmResourceGroupDeployment -ResourceGroupName $rgName -TemplateFile VirtualMachineTemplate.json -TemplateParameterFile Parameters.json
  </code></pre>
  
  <p>However, if I try to use the same template for Ansible <code>azure_rm_deployment</code> module in the following task:</p>
  
  <pre><code>- name: Ensure the VM is deployed to Azure
    azure_rm_deployment:
      state: present
      resource_group_name: "{{ resource_group_name }}"
      template: "{{ lookup('file', 'VirtualMachineTemplate.json') }}"
      parameters: "{{ lookup('file', 'Parameters.json') }}"
  </code></pre>
  
  <p>I get an error:</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "failed_deployment_operations": [], "msg": "Deployment failed with status code: 400 and message: The request content was invalid and could not be deserialized: 'Error converting value \"<a href="https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json" rel="nofollow">https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json</a>\" to type 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'. Path 'properties.parameters.$schema', line 1, position 142.'."}</p>
  </blockquote>
  
  <hr>
  
  <p>The error is caused by <code>parameters.json</code>. If I define the parameters directly in the task:</p>
  
  <pre><code>- name: Ensure the VM is deployed to Azure
    azure_rm_deployment:
      state: present
      resource_group_name: "{{ resource_group_name }}"
      template: "{{ lookup('file', 'VirtualMachineTemplate.json') }}"
      parameters:
        adminUserName:
          value: mytestacct1
        adminPassword:
          value: mytestpass1
  </code></pre>
  
  <p>It deploys the machine.</p>
  
  <p>I'm at loss here. Is there a modification required to the template for the Ansible module?</p>
  
  <hr>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>At the same time I can provision resources and VMs using <code>azure_rm_storageaccount</code>, <code>azure_rm_virtualmachine</code>, etc. modules, so I guess it's not a library problem; at least not the Microsoft Azure SDK for Python, which is 2.0.0rc5 per requirements.</p></li>
  <li><p>Just to make sure I also tried with <code>template_link</code> and <code>parameters_link</code> and the error message is the same.</p></li>
  </ul>