terraform azure OMS VM 扩展

joh*_*aul 2 azure azure-virtual-machine terraform azure-oms

我正在尝试将 OMS VM 扩展添加到 Linux 计算机,但它只是在部署过程中进行无休止的等待。运行 terraform plan 时没有错误。我正在使用以下代码片段以及 terraform 中的 VM 创建代码。这里发生的任何线索您可以在此处找到相应的 powershell 和 CLI 脚本 https://learn.microsoft.com/en-us/azure/virtual-machines /扩展/oms-linux

resource "azurerm_virtual_machine_extension" "test" {
  name                 = "${azurerm_virtual_machine.test.name}/OmsExtension"
  location             = "${azurerm_resource_group.test.location}"
  resource_group_name  = "${azurerm_resource_group.test.name}"
  virtual_machine_name = "${azurerm_virtual_machine.test.name}"
  publisher            = "Microsoft.EnterpriseCloud.Monitoring"
  type                 = "OmsAgentForLinux"
  type_handler_version = "1.4"


  settings = <<SETTINGS
      {
          "workspace ID" : "XXXX",
      }
  SETTINGS

    protected_settings = <<PROTECTED_SETTINGS
      {
          "workspace key" :  "XXXX"
      }
  PROTECTED_SETTINGS
}
Run Code Online (Sandbox Code Playgroud)

小智 5

乍一看,您的工作区密钥和 ID“密钥”似乎不正确,两个密钥中似乎都没有空格。Azure 应该提供更好的错误,例如提供的无效密钥。

我能够使用 Terraform 成功配置,它确实失败了几次,但通过此配置成功了。

resource "azurerm_virtual_machine_extension" "oms_mma" {
 name                          = "OMSExtension"
 location                      = "${var.vm_location}"
 resource_group_name           = "${var.resource_group_name}"
 virtual_machine_name          = "${var.vm_machine_name}"
 publisher                     = "Microsoft.EnterpriseCloud.Monitoring"
 type                          = "OmsAgentForLinux"
 type_handler_version          = "1.6"
 auto_upgrade_minor_version    = "True"

 settings = <<-BASE_SETTINGS
 {
   "workspaceId" : "myid"
 }
 BASE_SETTINGS

 protected_settings = <<-PROTECTED_SETTINGS
 {
   "workspaceKey" : "mykey"
 }
 PROTECTED_SETTINGS
}
Run Code Online (Sandbox Code Playgroud)