Skip to content

[Issue] Multiple log analytics workspaces created when using Azure App Insights and an Azure Container App #3497

@christiannagel

Description

@christiannagel

Output from azd version
Run azd version and copy and paste the output here:
azd version 1.7.0-beta.1-pr.3518885 (commit d62cc4c)

Describe the bug
Having an Azure App Insights resource together with container apps, two Log Analytics workspaces are created. I think there should be only one:

Using azd up, two log analytics workspaces are created:

  (✓) Done: Resource group: rg-codebreaker-12p4
  (x) Failed: Key Vault: codebreakercosmoskvzehizmlsmqemc
  (✓) Done: Log Analytics workspace: law-zehizmlsmqemc
  (✓) Done: Log Analytics workspace: law-appinsights-zehizmlsmqemc
  (✓) Done: Container Registry: acrzehizmlsmqemc
  (✓) Done: Application Insights: appinsights-zehizmlsmqemc
  (✓) Done: Container Apps Environment: cae-zehizmlsmqemc
  (✓) Done: Container App: redis

Using this app model:

    var insights = builder.AddAzureApplicationInsights("AppInsights");
    var redis = builder.AddRedis("redis");

    var cosmos = builder.AddAzureCosmosDB("codebreakercosmos")
        .AddDatabase("codebreaker");

    var gameAPIs = builder.AddProject<Projects.Codebreaker_GameAPIs>("gameapis")
        .WithReference(cosmos)
        .WithReference(redis)
        .WithReference(insights)
        .WithEnvironment("DataStore", dataStore)
        .WithReplicas(1);

    builder.AddProject<Projects.CodeBreaker_Blazor_Host>("blazor")
        .WithReference(gameAPIs)
        .WithReference(insights);

    builder.AddProject<Projects.CodeBreaker_Bot>("bot")
        .WithReference(gameAPIs)
        .WithReference(insights);

This is the generated manifest:

{
  "resources": {
    "AppInsights": {
      "type": "azure.bicep.v0",
      "connectionString": "{AppInsights.outputs.appInsightsConnectionString}",
      "path": "aspire.hosting.azure.bicep.appinsights.bicep",
      "params": {
        "appInsightsName": "appinsights",
        "logAnalyticsWorkspaceId": ""
      }
    },
    "redis": {
      "type": "container.v0",
      "connectionString": "{redis.bindings.tcp.host}:{redis.bindings.tcp.port}",
      "image": "redis:7.2.4",
      "bindings": {
        "tcp": {
          "scheme": "tcp",
          "protocol": "tcp",
          "transport": "tcp",
          "containerPort": 6379
        }
      }
    },
    "codebreakercosmos": {
      "type": "azure.bicep.v0",
      "connectionString": "{codebreakercosmos.secretOutputs.connectionString}",
      "path": "aspire.hosting.azure.bicep.cosmosdb.bicep",
      "params": {
        "databaseAccountName": "codebreakercosmos",
        "databases": [
          "codebreaker"
        ],
        "keyVaultName": ""
      }
    },
    "gameapis": {
      "type": "project.v0",
      "path": "../Codebreaker.GameAPIs/Codebreaker.GameAPIs.csproj",
      "env": {
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
        "ConnectionStrings__codebreakercosmos": "{codebreakercosmos.connectionString}",
        "ConnectionStrings__redis": "{redis.connectionString}",
        "APPLICATIONINSIGHTS_CONNECTION_STRING": "{AppInsights.connectionString}",
        "DataStore": "Cosmos"
      },
      "bindings": {
        "http": {
          "scheme": "http",
          "protocol": "tcp",
          "transport": "http"
        },
        "https": {
          "scheme": "https",
          "protocol": "tcp",
          "transport": "http"
        }
      }
    },
    "blazor": {
      "type": "project.v0",
      "path": "../CodeBreaker.Blazor.Host/CodeBreaker.Blazor.Host.csproj",
      "env": {
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
        "APPLICATIONINSIGHTS_CONNECTION_STRING": "{AppInsights.connectionString}",
        "services__gameapis__0": "{gameapis.bindings.http.url}",
        "services__gameapis__1": "{gameapis.bindings.https.url}"
      },
      "bindings": {
        "http": {
          "scheme": "http",
          "protocol": "tcp",
          "transport": "http"
        },
        "https": {
          "scheme": "https",
          "protocol": "tcp",
          "transport": "http"
        }
      }
    },
    "bot": {
      "type": "project.v0",
      "path": "../CodeBreaker.Bot/CodeBreaker.Bot.csproj",
      "env": {
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
        "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
        "APPLICATIONINSIGHTS_CONNECTION_STRING": "{AppInsights.connectionString}",
        "services__gameapis__0": "{gameapis.bindings.http.url}",
        "services__gameapis__1": "{gameapis.bindings.https.url}"
      },
      "bindings": {
        "http": {
          "scheme": "http",
          "protocol": "tcp",
          "transport": "http"
        },
        "https": {
          "scheme": "https",
          "protocol": "tcp",
          "transport": "http"
        }
      }
    }
  }
}

Expected behavior

I expect to have one log analytics workspace created from the App Insights resource, and this workspace to be used with project resources referencing app insights.

Environment
Information on your environment:
* Version 17.10.0 Preview 1.0
* aspire 8.0.0-preview.5.24156.15/8.0.100

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions