{"record":{"id":"c0a2babc1d59cb7d","repo":"microsoft/aspire","slug":"connection-string-for-kusto-resource-resourcebuilder","errorCode":null,"errorMessage":"Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.","messagePattern":"Connection string for Kusto resource '(.+?)' is not set\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kusto/AzureKustoBuilderExtensions.cs","lineNumber":386,"sourceCode":"        static ResourceCommandState UpdateStateWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, UpdateCommandStateContext context)\n        {\n            // The web explorer will only auto-connect to allowed domains, so do not show the command when running as an emulator.\n            if (resourceBuilder.Resource.IsEmulator)\n            {\n                return ResourceCommandState.Hidden;\n            }\n\n            return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;\n        }\n\n        static async Task<ExecuteCommandResult> OnOpenInKustoExplorerDesktop(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, ExecuteCommandContext context)\n        {\n            var connectionString = await resourceBuilder\n                .Resource\n                .ConnectionStringExpression\n                .GetValueAsync(context.CancellationToken)\n                .ConfigureAwait(false) ??\n                throw new DistributedApplicationException($\"Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.\");\n\n            var launcher = new KustoClientToolLauncher();\n            var result = launcher.TryLaunchKustoExplorer(title: \"\", resourceBuilder.Resource.Name, connectionString, requestText: \"\");\n\n            return result ? CommandResults.Success() : CommandResults.Failure(\"Failed to launch Kusto Explorer\");\n        }\n\n        static async Task<ExecuteCommandResult> OnOpenInKustoExplorerWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, ExecuteCommandContext context)\n        {\n            var connectionString = await resourceBuilder\n                .Resource\n                .ConnectionStringExpression\n                .GetValueAsync(context.CancellationToken)\n                .ConfigureAwait(false) ??\n                throw new DistributedApplicationException($\"Connection string for Kusto resource '{resourceBuilder.Resource.Name}' is not set.\");\n\n            var launcher = new KustoClientToolLauncher();\n            var result = launcher.TryLaunchKustoWebExplorer(title: \"\", resourceBuilder.Resource.Name, connectionString, requestText: \"\");","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kusto/AzureKustoBuilderExtensions.cs#L368-L404","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Assign a connection string to the Kusto resource (WithConnectionString or backing parameter) before using the Launch Kusto Explorer command.","If the connection string comes from Azure provisioning, wait until provisioning completes so the expression resolves.","Check that a referenced parameter/config value for the connection string is populated.","Avoid invoking client-tool commands on resources that are still being provisioned."],"exampleFix":"// before\nvar kusto = builder.AddAzureKustoCluster(\"kusto\"); // no connection string source\n// after\nvar kusto = builder.AddAzureKustoCluster(\"kusto\")\n    .WithConnectionString(builder.AddParameter(\"kusto-cs\"));","handlingStrategy":"validation","validationCode":"var cs = await resource.ConnectionStringExpression.GetValueAsync(ct);\nif (string.IsNullOrEmpty(cs)) throw new InvalidOperationException(\"Cannot launch Kusto Explorer: resource has no connection string yet.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use client-tool commands after the resource is running/provisioned.","Ensure every Kusto resource has a connection string source (parameter or emulator).","Prefer RunAsEmulator locally for deterministic connection strings.","Wait for provisioning outputs (Bicep) before launching external tools."],"tags":["aspire","azure-kusto","custom-command","connection-string"],"backgroundTag":"missing-config-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}