davidobrien1985 / davidobrien1985.github.io

1 stars 0 forks source link

Azure vm insights monitoring using terraform #23

Open basavarajb opened 3 years ago

basavarajb commented 3 years ago

I'm getting the following error

Code="VMExtensionProvisioningError" Message="VM has reported a failure when processing extension 'vm-insights-monitorAgent-vmazpcuwldship3'. Error message: "Failed to enable application monitoring for IIS: System.IO.FileNotFoundException: Cannot find applicationHost.config at C:\windows\System32\inetsrv\config\applicationHost.config\r\nFile name: 'C:\windows\System32\inetsrv\config\applicationHost.config'\r\n at Microsoft.ApplicationInsights.Redfield.Configurator.RuntimeConfigurators.IISConfigurator.UpdateApplicationHostConfig(IAppInsightsConfiguratorLogger logger, Boolean enable, Boolean skipMissingApplicationHostConfig, ISystem system)\r\n at Microsoft.ApplicationInsights.Redfield.Configurator.RuntimeConfigurators.IISConfigurator.Enable(IRuntimePaths runtimePaths, IAppInsightsConfiguratorLogger logger, Boolean writeToApplicationHostConfig, Boolean skipMissingApplicationHostConfig, ISystem system)\r\n at Microsoft.ApplicationInsights.Redfield.Configurator.RedfieldConfigurator.Enable(IRuntimePaths runtimePaths, IAppInsightsConfiguratorLogger logger, RedfieldConfiguration redfieldConfiguration, Boolean enableInstrumentationEngine, Boolean writeToApplicationHostConfig, Boolean skipMissingApplicationHostConfig)\r\n at Microsoft.ApplicationInsights.VmExtensionHandler.VmExtensionHandler.Enable(HandlerEnvironment handlerEnvironment, String configSequenceNumber)"\r\n\r\n "

Anything do i need to run using custom extension



resource "azurerm_virtual_machine_extension" "vm_insight_monitor_agent" {
  name                  = "vm-insights-monitorAgent-${var.vm_name}"
  virtual_machine_id    = var.vm_id
  publisher             = "Microsoft.Azure.Diagnostics"
  type                  = "ApplicationMonitoringWindows"
  type_handler_version  = "2.8"
  auto_upgrade_minor_version = true
  depends_on          = [
    azurerm_virtual_machine_extension.machine_extension_Diagnostics,
    azurerm_virtual_machine_extension.monitor_DependencyAgent_agent,
    azurerm_virtual_machine_extension.monitor_agent
  ]
  settings = <<SETTINGS
      {
        "RedfieldConfiguration": {
          "InstrumentationKeyMap": {
            "Filters": [
              {
                 "AppFilter": ".*",
                "MachineFilter": ".*",
                "InstrumentationSettings" : {
                  "InstrumentationKey": "${var.appinsights_InstrumentationKey}"
                }
              }
            ]
          }
        }
      }
SETTINGS

  protected_settings = <<PROTECTED_SETTINGS
        {}
PROTECTED_SETTINGS

}