Azure Java App Service Fails to Start Due to "Tag value too large" Error in Application Insights

I am encountering an issue where our Azure Java App Service is taking an excessively long time to start, eventually leading to a timeout. The error appears to be related to a tag size limit in the Azure Web App’s Activity log. The specific error message is:

Tag value too large. Following tag value 'InstrumentationKey=[MASKED];IngestionEndpoint=https://germanywestcentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://germanywestcentral.livediagnostics.monitor.azure.com/;ApplicationId=[MASKED]' exceeded the maximum length. Maximum allowed length for tag value - '256' characters.

We are deploying our application using Terraform with the azurerm provider, version ~> 3.115.0.

I’ve searched extensively for solutions but have not found any relevant discussions or fixes. I have a few questions regarding this issue:

  1. Why is there an attempt to set such a long tag value? Is this expected behavior when configuring Application Insights with the App Service?
  2. How can I fix or reduce the tag size? Are there any configurations or best practices to prevent this from happening?
  3. Has anyone experienced a similar issue? If so, what steps did you take to resolve it?

Below is the relevant portion of our Terraform configuration for the Web App:

resource "azurerm_linux_web_app" "[MASKED]" {
  name                = "app-${local.app_naming_component}"
  resource_group_name = data.azurerm_resource_group.[MASKED].name
  location            = var.location
  service_plan_id     = azurerm_service_plan.[MASKED].id

  site_config {
    application_stack {
      docker_image_name   = "${var.image_name}:${var.image_tag}"
      docker_registry_url = "https://${data.azurerm_container_registry.shared.login_server}"
    }

    container_registry_use_managed_identity = "true"
  }

  identity {
    type = "SystemAssigned"
  }

  app_settings = {
    APPINSIGHTS_INSTRUMENTATIONKEY             = data.azurerm_application_insights.[MASKED].instrumentation_key
    APPLICATIONINSIGHTS_CONNECTION_STRING      = data.azurerm_application_insights.[MASKED].connection_string
    ApplicationInsightsAgent_EXTENSION_VERSION = "~3"
    APPLICATIONINSIGHTS_STATSBEAT_DISABLED     = true
    WEBSITES_PORT                              = 8080
    SPRING_PROFILES_ACTIVE                     = var.environment
    DOCKER_ENABLE_CI                           = "true"
  }
}

And here is the Terraform configuration for Application Insights and the Log Analytics workspace:

resource "azurerm_log_analytics_workspace" "[MASKED]" {
  name                = "log-${local.app_naming_component}"
  resource_group_name = azurerm_resource_group.[MASKED].name
  location            = azurerm_resource_group.[MASKED].location
  sku                 = "PerGB2018"
  retention_in_days   = 30
  tags                = var.tags
}

resource "azurerm_application_insights" "[MASKED]" {
  name                 = "appi-${local.app_naming_component}"
  resource_group_name  = azurerm_resource_group.[MASKED].name
  location             = azurerm_resource_group.[MASKED].location
  workspace_id         = azurerm_log_analytics_workspace.[MASKED].id
  application_type     = "java"
  retention_in_days    = 30
  daily_data_cap_in_gb = 1
}

I would greatly appreciate any insights or recommendations to address this issue.