microsoft/aspire · error · InvalidOperationException

Import is disabled.

Error message

Import is disabled.

What it means

TelemetryImportService.ImportAsync first checks IsImportEnabled, which reflects whether the dashboard was launched with telemetry import allowed. When the feature is off, the method throws InvalidOperationException("Import is disabled.") before touching the stream — import is opt-in for security reasons.

Solutions

  1. Enable telemetry import on dashboard startup (set the telemetry-import feature configuration, e.g. Dashboard:Otlp:WithTelemetryImport / corresponding CLI flag)
  2. Check TelemetryImportService.IsImportEnabled before attempting an import and surface a friendly message
  3. Restart the dashboard with import enabled, then retry the import
  4. If import isn't available, view telemetry live via OTLP instead of importing a file

Example fix

// before
await telemetryImportService.ImportAsync(file.Name, fileStream, ct);
// after
if (!telemetryImportService.IsImportEnabled)
{
    throw new InvalidOperationException("Enable telemetry import on the dashboard before importing files.");
}
await telemetryImportService.ImportAsync(file.Name, fileStream, ct);
Defensive patterns

Strategy: validation

Validate before calling

if (!telemetryImportService.IsImportEnabled)
    throw new InvalidOperationException("Telemetry import is disabled. Start the dashboard with telemetry import enabled.");

Try / catch

try
{
    await importService.ImportAsync(fileName, stream, ct);
}
catch (InvalidOperationException ex) when (ex.Message == "Import is disabled.")
{
    console.WriteLine("Import is disabled: restart the dashboard with telemetry import enabled.");
}

Prevention

When it happens

Trigger: Calling ImportAsync when the dashboard was started without the import-enabling configuration (the ASPIRE_DASHBOARD_OTLP_WITH_TELEMETRY_IMPORT / enable-telemetry-import settings), or in a client embedding the dashboard with import disabled by default.

Common situations: Running the dashboard in production/default mode where import is disabled; forgetting to pass the feature flag or launch argument when automating imports; tests invoking the service against a default-constructed options object.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/3207ba88ad1f6746. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Dashboard/Model/TelemetryImportService.cs:64

        _logger = logger;
        _activitySource = activitySource.ActivitySource;
    }

    /// <summary>
    /// Imports telemetry data from a file stream.
    /// </summary>
    /// <param name="fileName">The name of the file being imported.</param>
    /// <param name="stream">The file stream.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the async operation.</returns>
    /// <exception cref="InvalidOperationException">Thrown when import is disabled.</exception>
    public async Task ImportAsync(string fileName, Stream stream, CancellationToken cancellationToken)
    {
        using var activity = _activitySource.StartActivity("Import telemetry data", ActivityKind.Internal);

        if (!IsImportEnabled)
        {
            throw new InvalidOperationException("Import is disabled.");
        }

        await ImportCoreAsync(fileName, stream, allowZipFile: true, cancellationToken).ConfigureAwait(false);
    }

    private async Task ImportCoreAsync(string fileName, Stream stream, bool allowZipFile, CancellationToken cancellationToken)
    {
        var extension = Path.GetExtension(fileName).ToLowerInvariant();

        switch (extension)
        {
            case ".zip":
                if (!allowZipFile)
                {
                    // Allowing zip file is a flag to not extract zip files inside zip files. Avoid unexpected recursion.
                    goto default;
                }

View on GitHub (pinned to 25830f84bd)