title: Issue with install DSC extension on Azure VM during deployment using Terraform
body: <p>I am trying to use the information in this article:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-template#default-configuration-script" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-template#default-configuration-script</a></p>
  
  <p>to onboard a VM to Azure Automation at deployment time and apply a configuration.</p>
  
  <p>I am using Terraform to do the deployment, below is the code I am using for the extensions:</p>
  
  <pre><code>resource "azurerm_virtual_machine_extension" "cse-dscconfig" {
    name                    = "${var.vm_name}-dscconfig-cse"
    location                = "${azurerm_resource_group.my_rg.location}"
    resource_group_name     = "${azurerm_resource_group.my_rg.name}"
    virtual_machine_name    = "${azurerm_virtual_machine.my_vm.name}"
    publisher               = "Microsoft.Powershell"
    type                    = "DSC"
    type_handler_version    = "2.76"
    depends_on              = ["azurerm_virtual_machine.my_vm"]
  
    settings = &lt;&lt;SETTINGS
          {
            "configurationArguments": {
                "RegistrationUrl": "${var.endpoint}",
                "NodeConfigurationName": "VMConfig"
            }
          }
          SETTINGS
  
    protected_settings = &lt;&lt;PROTECTED_SETTINGS
          {
                  "configurationArguments": {
                    "registrationKey": {
                      "userName": "NOT_USED",
                      "Password": "${var.key}"
                    }
                  }
          }
          PROTECTED_SETTINGS
  }
  </code></pre>
  
  <p>I am getting the <code>RegistrationURL</code> value at execution time by running the command below and passing the value into Terraform:</p>
  
  <pre><code>$endpoint = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).Endpoint
  </code></pre>
  
  <p>I am getting the <code>Password</code> value at execution time by running the command below and passing the value into Terraform:</p>
  
  <pre><code>$key = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).PrimaryKey
  </code></pre>
  
  <p>I can tell from the logs on the VM that the extension is getting installed but never registers with the Automation Account.</p>