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:
Why is there an attempt to set such a long tag value? Is this expected behavior when configuring Application Insights with the App Service?
How can I fix or reduce the tag size? Are there any configurations or best practices to prevent this from happening?
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.
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.
APPINSIGHTS_INSTRUMENTATIONKEY
environment variable instead of the full APPLICATIONINSIGHTS_CONNECTION_STRING
. The instrumentation key is much shorter and usually sufficient for basic Application Insights functionality.Look through the app_settings
in the Terraform configuration and remove any settings that are not necessary.
.tf file:
provider "azurerm" {
features {}
version = "~> 3.115.0"
}
# Resource Group
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "East US"
}
# Service Plan
resource "azurerm_service_plan" "example" {
name = "example-service-plan"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
os_type = "Linux"
sku_name = "P1v2"
}
# Application Insights
resource "azurerm_application_insights" "example" {
name = "example-ai"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
application_type = "web"
}
# Log Analytics Workspace
resource "azurerm_log_analytics_workspace" "example" {
name = "example-log-workspace"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "PerGB2018"
retention_in_days = 30
# Tags have been removed to avoid exceeding tag length limits
}
# Linux Web App
resource "azurerm_linux_web_app" "example" {
name = "example-web-app"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
service_plan_id = azurerm_service_plan.example.id
site_config {
application_stack {
docker_image_name = "example-image"
docker_registry_url = "https://example.com"
}
container_registry_use_managed_identity = true
}
identity {
type = "SystemAssigned"
}
app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.example.instrumentation_key
# Using instrumentation key instead of a long connection string
ApplicationInsightsAgent_EXTENSION_VERSION = "~3"
APPLICATIONINSIGHTS_STATSBEAT_DISABLED = "true"
WEBSITES_PORT = 8080
}
# Example of applying short, meaningful tags
tags = {
Environment = "Production"
Owner = "TeamName"
}
}
Intialized:
Deployed: