简体   繁体   English

Terraform Azure 来自本地脚本的 VM 扩展自定义脚本

[英]Terraform Azure VM Extension Custom Script from Local Script

I'm trying to deploy Azure Windows VM with VM extension by Terraform that will install ADDS role for the Windows VM.我正在尝试部署 Azure Windows VM,VM 扩展为 Terraform,它将为 ZAEAZ063489CE3AA9BB46 安装 ADDS 角色。

I have one Powershell script file for the installation named install_adds.ps1 from my local machine我有一个 Powershell 脚本文件,用于从我的本地计算机安装名为install_adds.ps1

The Terraform file of VM Extension as below: VM Extension的Terraform文件如下:

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我已部署 VM 扩展 Terraform 文件但无法正常工作

I think my Terraform file syntax is wrong and the Windows does not run my PowerShell script.我认为我的 Terraform 文件语法错误,并且 Windows 没有运行我的 PowerShell 脚本。

Any way can run my local PowerShell Script by Terraform VM Extension file?任何方式都可以通过 Terraform VM 扩展文件运行我的本地 PowerShell 脚本?

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.根据您发布的架构,您可能正在尝试在基于 Windows 的 VM 上部署错误的客户脚本扩展(Linux VM 的 CSE)。

Below extensions schemas what you could use depending on the OS:根据操作系统,您可以使用以下扩展架构:

Linux : Linux

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

Windows : Windows

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

You used on Windows:您在 Windows 上使用过:

publisher            = "Microsoft.Azure.Extensions"
type                 = "CustomScript"
type_handler_version = "2.0"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM