terraform azure OMS VM扩展

时间:2018-05-21 00:44:30

标签: azure terraform azure-virtual-machine azure-oms

我正在尝试将OMS VM扩展添加到Linux机器,但它只是在部署期间无休止的等待。运行terraform计划时没有错误。 我在terraform中使用以下代码和VM创建代码。这里发生了什么线索 您可以在此处找到相应的powershell和CLI脚本 https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/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
}

1 个答案:

答案 0 :(得分:1)

乍一看,您的工作区密钥和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
}