2

I'm trying to deploy Azure Windows VM with VM extension by Terraform that will install ADDS role for the Windows VM.

I have one Powershell script file for the installation named install_adds.ps1 from my local machine

The Terraform file of VM Extension as below:

resource "azurerm_virtual_machine_extension" "main" {
  name                 = "extensionTest"
  virtual_machine_id   = azurerm_virtual_machine.main.id
  publisher            = "Microsoft.Azure.Extensions"
  type                 = "CustomScript"
  type_handler_version = "2.0"

  settings = <<SETTINGS
    {
        "commandToExecute": "powershell.exe ./install_adds.ps1"
    }
SETTINGS
}

I have deployed the VM Extension Terraform file but not working

I think my Terraform file syntax is wrong and the Windows does not run my PowerShell script.

Any way can run my local PowerShell Script by Terraform VM Extension file?

1 Answer 1

5

Based on the schemas you posted, you might be trying to deploy the wrong customer script extension (CSE for Linux VM) on Windows based VM.

Below extensions schemas what you could use depending on the OS:

Linux:

"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.1",

Windows:

    "publisher": "Microsoft.Compute",
    "type": "CustomScriptExtension",
    "typeHandlerVersion": "1.10",

You used on Windows:

publisher            = "Microsoft.Azure.Extensions"
type                 = "CustomScript"
type_handler_version = "2.0"
Sign up to request clarification or add additional context in comments.

2 Comments

Hey @chris1126. I just wondering if above steps helped to resolve your issue.
I'm banging my head with the wall because of this for 3 days. Where can I find which one to use with which OS? Though still not able to accomplish what I want but this is huge thing. I figured out when error message in pipeline was sending me to linux trouble shooting page for extension but windows one had "Microsoft.Compute" extension.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.