microsoft/aspire · error · DistributedApplicationException

Connection string for Kusto resource

Error message

Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.

What it means

The 'Launch Kusto Explorer' custom command on an Azure Kusto resource resolves the connection string from the resource's ConnectionStringExpression to pass to the launched tool. If the expression resolves to null, a DistributedApplicationException is thrown because Kusto Explorer cannot be launched without a connection string.

Solutions

  1. Assign a connection string to the Kusto resource (WithConnectionString or backing parameter) before using the Launch Kusto Explorer command.
  2. If the connection string comes from Azure provisioning, wait until provisioning completes so the expression resolves.
  3. Check that a referenced parameter/config value for the connection string is populated.
  4. Avoid invoking client-tool commands on resources that are still being provisioned.

Example fix

// before
var kusto = builder.AddAzureKustoCluster("kusto"); // no connection string source
// after
var kusto = builder.AddAzureKustoCluster("kusto")
    .WithConnectionString(builder.AddParameter("kusto-cs"));
Defensive patterns

Strategy: validation

Validate before calling

var cs = await resource.ConnectionStringExpression.GetValueAsync(ct);
if (string.IsNullOrEmpty(cs)) throw new InvalidOperationException("Cannot launch Kusto Explorer: resource has no connection string yet.");

Prevention

When it happens

Trigger: Clicking/invoking the Kusto Explorer custom command on a resource whose ConnectionStringExpression.GetValueAsync returns null — the resource has no connection string at command-execution time.

Common situations: Invoking the dashboard command while the resource is still provisioning or when the connection string was intentionally deferred (e.g. value-only resource without a connection string).

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Kusto/AzureKustoBuilderExtensions.cs:386

        static ResourceCommandState UpdateStateWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, UpdateCommandStateContext context)
        {
            // The web explorer will only auto-connect to allowed domains, so do not show the command when running as an emulator.
            if (resourceBuilder.Resource.IsEmulator)
            {
                return ResourceCommandState.Hidden;
            }

            return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;
        }

        static async Task<ExecuteCommandResult> OnOpenInKustoExplorerDesktop(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, ExecuteCommandContext context)
        {
            var connectionString = await resourceBuilder
                .Resource
                .ConnectionStringExpression
                .GetValueAsync(context.CancellationToken)
                .ConfigureAwait(false) ??
                throw new DistributedApplicationException($"Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.");

            var launcher = new KustoClientToolLauncher();
            var result = launcher.TryLaunchKustoExplorer(title: "", resourceBuilder.Resource.Name, connectionString, requestText: "");

            return result ? CommandResults.Success() : CommandResults.Failure("Failed to launch Kusto Explorer");
        }

        static async Task<ExecuteCommandResult> OnOpenInKustoExplorerWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, ExecuteCommandContext context)
        {
            var connectionString = await resourceBuilder
                .Resource
                .ConnectionStringExpression
                .GetValueAsync(context.CancellationToken)
                .ConfigureAwait(false) ??
                throw new DistributedApplicationException($"Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.");

            var launcher = new KustoClientToolLauncher();
            var result = launcher.TryLaunchKustoWebExplorer(title: "", resourceBuilder.Resource.Name, connectionString, requestText: "");

View on GitHub (pinned to 25830f84bd)