I defined a CustomScriptExtension for Azure VM in Terraform:

```
resource "azurerm_virtual_machine_extension" "test" {
    name = "WinRM"
    location = "South Central US"
    resource_group_name = "${azurerm_resource_group.test.name}"
    virtual_machine_name = "${azurerm_virtual_machine.test.name}"
    publisher = "Microsoft.Compute"
    type = "CustomScriptExtension"
    type_handler_version = "1.8"

    settings = <<SETTINGS
    {
        "fileUris": "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1",
        "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"
    }
SETTINGS

}

```

However I get (the same error is visible in Azure portal in VM extensions):

> 
> azurerm\_virtual\_machine\_extension.test: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="VMExtensionProvisioningError" Message="VM has reported a failure when processing extension 'WinRM'. Error message: \"Invalid handler configuration. Exiting. Error Message: Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. \"."
> 
> 
> 

The same parameters executed as an [Azure deployment](https://github.com/techraf/azure-enable-winrm/blob/e7169744248c626b613517afc349b6bab6552b9f/azuredeploy.json) works with no problems (relevant excerpts below):

```
"fileUris": {
  "type": "string",
  "defaultValue": "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1",
  "metadata": {
    "description": "The uri list of files. Split by a space."
  }
},

```

```
"settings": {
  "fileUris": "[split(parameters('fileUris'), ' ')]",
  "commandToExecute": "[parameters('commandToExecute')]"
}

```

Am I missing something, or is it a bug in Terraform?

---

Some debugging:

* If I replace the settings with just:

```
{
    "commandToExecute": "mkdir C:\\Test"
}

```

the directory gets created, so the problem is with `fileUris`.
* If I replace `fileUris` in the settings JSON with `fileUri` (which should be wrong):

```
{
    "fileUri": "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1",
    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"
}

```

there is no the `Encountered 'Text' with name '', namespace ''. \".` error, `powershell.exe` fires and reports missing `ConfigureRemotingForAnsible.ps1`.