microsoft/aspire · error · InvalidOperationException

The dashboard is not enabled for this application.

Error message

The dashboard is not enabled for this application.

What it means

The Aspire dashboard can be disabled via DistributedApplicationOptions.DisableDashboard. GetDashboardUrlAsync requires a dashboard resource to resolve a URL, so it throws when the application was configured without one.

Solutions

  1. Enable the dashboard (remove DisableDashboard=true / unset ASPIRE_DISABLE_DASHBOARD) if the URL is needed.
  2. Guard the call: check applicationOptions.DisableDashboard before invoking GetDashboardUrlAsync.
  3. Use resource endpoints directly instead of the dashboard URL when the dashboard is intentionally off.

Example fix

// before
var url = await app.GetDashboardUrlAsync();
// after
var opts = app.Services.GetRequiredService<DistributedApplicationOptions>();
if (!opts.DisableDashboard)
{
    var url = await app.GetDashboardUrlAsync();
}
Defensive patterns

Strategy: validation

Validate before calling

var opts = app.Services.GetRequiredService<DistributedApplicationOptions>();
if (opts.DisableDashboard)
{
    // dashboard is off; do not call GetDashboardUrlAsync
}

Type guard

static bool DashboardEnabled(DistributedApplication app) =>
    !app.Services.GetRequiredService<DistributedApplicationOptions>().DisableDashboard;

Try / catch

try
{
    var url = await app.GetDashboardUrlAsync(ct);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("dashboard is not enabled"))
{
    url = null; // app intentionally runs without a dashboard
}

Prevention

When it happens

Trigger: Calling app.GetDashboardUrlAsync() when the AppHost was built with builder.Configuration or options setting DisableDashboard=true (or ASPIRE_DISABLE_DASHBOARD set), then attempting to fetch the dashboard URL.

Common situations: Test setups that disable the dashboard for speed or headless CI runs; apps configured with dashboard disabled for production-like runs but reusing testing helpers that assume it exists.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs:80

    /// </code>
    /// </example>
    [AspireExportIgnore(Reason = "Use the exported getDashboardUrl overload without a cancellation token.")]
    public static async Task<Uri> GetDashboardUrlAsync(
        this DistributedApplication app,
        CancellationToken cancellationToken = default)
    {
        ArgumentNullException.ThrowIfNull(app);

        var executionContext = app.Services.GetRequiredService<DistributedApplicationExecutionContext>();
        if (executionContext.IsPublishMode)
        {
            throw new InvalidOperationException(Properties.Resources.DashboardUrlPublishModeExceptionMessage);
        }

        var applicationOptions = app.Services.GetRequiredService<DistributedApplicationOptions>();
        if (applicationOptions.DisableDashboard)
        {
            throw new InvalidOperationException(Properties.Resources.DashboardDisabledExceptionMessage);
        }

        ThrowIfNotStarted(app, Properties.Resources.DashboardUrlApplicationNotStartedExceptionMessage);
        cancellationToken.ThrowIfCancellationRequested();

        await app.ResourceNotifications.WaitForResourceHealthyAsync(
            DashboardResourceName,
            WaitBehavior.StopOnResourceUnavailable,
            cancellationToken).ConfigureAwait(false);

        var applicationModel = app.Services.GetRequiredService<DistributedApplicationModel>();
        if (!applicationModel.Resources.TryGetByName(DashboardResourceName, out var resource) ||
            resource is not IResourceWithEndpoints dashboardResource)
        {
            throw new InvalidOperationException(Properties.Resources.DashboardUrlUnavailableExceptionMessage);
        }

        var httpsEndpoint = dashboardResource.GetEndpoint("https");

View on GitHub (pinned to 25830f84bd)