microsoft/aspire · error · InvalidOperationException

A DataLakeServiceClient could not be configured. Ensure…

Error message

A DataLakeServiceClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or specify a 'ConnectionString' or 'ServiceUri' in the '{configurationSectionName}' configuration section.

What it means

Aspire's Azure Data Lake Storage integration throws this when neither ConnectionString nor ServiceUri is configured for DataLakeServiceClient. The Data Lake client needs one of these to locate the storage account; the integration throws a descriptive error rather than letting the SDK fail.

Solutions

  1. Add "ConnectionStrings": { "<name>": "<adls connection string or endpoint>" }
  2. Set "ServiceUri": "https://<account>.dfs.core.windows.net/" in the config section
  3. Wire the resource in the AppHost: builder.AddAzureDataLakeStorage("adls") then .WithReference(...)
  4. Double-check the connectionName matches the ConnectionStrings key

Example fix

// before
builder.AddAzureDataLakeServiceClient("datalake"); // key missing
// after
"ConnectionStrings": { "datalake": "https://acct.dfs.core.windows.net/" }
// builder.AddAzureDataLakeServiceClient("datalake");
Defensive patterns

Strategy: validation

Validate before calling

if (builder.Configuration.GetConnectionString("datalake") is null &&
    builder.Configuration["Aspire:Azure:Storage:Files:DataLake:ServiceUri"] is null)
    throw new InvalidOperationException("Provide ConnectionStrings:datalake or a ServiceUri for ADLS.");

Prevention

When it happens

Trigger: Calling builder.AddAzureDataLakeServiceClient(connectionName) with no 'ConnectionStrings:<connectionName>' entry and no ConnectionString/ServiceUri under 'Aspire:Azure:Storage:Files:DataLake'.

Common situations: Missing WithReference in the AppHost for the ADLS resource; connection name typo; running locally with no user secrets configured.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src/Components/Aspire.Azure.Storage.Files.DataLake/AspireDataLakeExtensions.DataLakeComponent.cs:32

public static partial class AspireDataLakeExtensions
{
    private sealed class DataLakeComponent
        : AzureComponent<AzureDataLakeSettings, DataLakeServiceClient, DataLakeClientOptions>
    {
        protected override IAzureClientBuilder<DataLakeServiceClient, DataLakeClientOptions> AddClient(
            AzureClientFactoryBuilder azureFactoryBuilder,
            AzureDataLakeSettings settings,
            string connectionName,
            string configurationSectionName)
            => ((IAzureClientFactoryBuilderWithCredential)azureFactoryBuilder)
                .RegisterClientFactory<DataLakeServiceClient, DataLakeClientOptions>(
                    (options, cred) =>
                    {
                        var connectionString = settings.ConnectionString;
                        if (string.IsNullOrEmpty(connectionString) && settings.ServiceUri is null)
                        {
                            throw new InvalidOperationException(
                                $"A DataLakeServiceClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or specify a 'ConnectionString' or 'ServiceUri' in the '{configurationSectionName}' configuration section.");
                        }

                        return !string.IsNullOrEmpty(connectionString) ?
                            new DataLakeServiceClient(connectionString, options) :
                            cred is not null ? new DataLakeServiceClient(settings.ServiceUri, cred, options) :
                                new DataLakeServiceClient(settings.ServiceUri, options);
                    },
                    requiresCredential: false);

        protected override bool GetHealthCheckEnabled(AzureDataLakeSettings settings) => !settings.DisableHealthChecks;

        protected override bool GetMetricsEnabled(AzureDataLakeSettings settings) => false;

        protected override bool GetTracingEnabled(AzureDataLakeSettings settings) => !settings.DisableTracing;

        protected override TokenCredential? GetTokenCredential(AzureDataLakeSettings settings) => settings.Credential;

View on GitHub (pinned to 25830f84bd)