'Terraform issue setting up VM logging 'Microsoft.EnterpriseCloud.Monitoring' and type 'MicrosoftMonitoringAgent'

I'm trying to provision a windows VM with logging with Terraform, But I had several different errors trying to add the required components. The current error is

No version found in the artifact repository that satisfies the requested version '1.0' for VM extension with publisher 'Microsoft.EnterpriseCloud.Monitoring' and type 'MicrosoftMonitoringAgent'

resource "azurerm_log_analytics_workspace" "law" {
  name                      = "${local.vm_name}-law"
  location                  = azurerm_resource_group.rg.location
  resource_group_name       = azurerm_resource_group.rg.name
  sku                       = "PerGB2018"
  retention_in_days         = "30"
  internet_ingestion_enabled= true
  internet_query_enabled    = false
  tags                      = local.common_tags
}

resource "azurerm_log_analytics_solution" "vminsights" {
  solution_name         = "VMInsights"
  location              = azurerm_resource_group.rg.location
  resource_group_name   = azurerm_resource_group.rg.name
  workspace_resource_id = azurerm_log_analytics_workspace.law.id
  workspace_name        = azurerm_log_analytics_workspace.law.name
  tags                  = local.common_tags

  plan {
    publisher = "Microsoft"
    product   = "OMSGallery/VMInsights"
  }
}

resource "azurerm_virtual_machine_extension" "omsext" {
  name                  = "OMSExtension"
  virtual_machine_id    = azurerm_virtual_machine.iis-vm.id
  publisher             = "Microsoft.EnterpriseCloud.Monitoring"
  type                  = "MicrosoftMonitoringAgent"
  type_handler_version  = "1.0"
  auto_upgrade_minor_version = true

  settings = <<SETTINGS
    {
      "workspaceId": "${azurerm_log_analytics_workspace.law.workspace_id}"
    }
SETTINGS
  protected_settings = <<PROTECTED_SETTINGS
    {
      "workspaceKey": "${azurerm_log_analytics_workspace.law.primary_shared_key}"
    }
PROTECTED_SETTINGS  

  tags                       = local.common_tags
}

resource "azurerm_virtual_machine_extension" "DAAgent" {
  name                       = "${local.vm_name}-daa"
  virtual_machine_id         = azurerm_virtual_machine.iis-vm.id
  publisher                  = "Microsoft.Azure.Monitoring.DependencyAgent"
  type                       = "DependencyAgentWindows"
  type_handler_version       = "9.10"
  auto_upgrade_minor_version = true
  tags                       = local.common_tags
} 

    variable "iis_vm_image" {
      type        = map(string)
      description = "Virtual machine source image information"
      default     = {
        publisher = "MicrosoftWindowsServer"
        offer     = "WindowsServer"
        sku       = "2022-datacenter-azure-edition"
        version   = "latest"
      }
    }

I have tried the 1.0.x.x version, but then get an invalid version message


Solution 1:[1]

I see that you put type_handler_version = "1.0" however the extension type MicrosoftMonitoringAgent has version format 1.0.X.X

The Publisher, Type of Virtual Machine Extensions and version of the extension to use can be found using the Azure CLI, via:

az vm extension image list --location mylocation -o table

Here is an output of the above command: enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andriy Bilous