{"record":{"id":"5af0cbecabe9ab3f","repo":"microsoft/aspire","slug":"a-blobserviceclient-could-not-be-configured-ensure-valid","errorCode":null,"errorMessage":"A BlobServiceClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or specify a 'ConnectionString' or 'ServiceUri' in the '{configurationSectionName}' configuration section.","messagePattern":"A BlobServiceClient could not be configured\\. Ensure valid connection information was provided in 'ConnectionStrings:(.+?)' or specify a 'ConnectionString' or 'ServiceUri' in the '(.+?)' configuration section\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.BlobStorageComponent.cs","lineNumber":30,"sourceCode":"using Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Diagnostics.HealthChecks;\n\nnamespace Microsoft.Extensions.Hosting;\n\npartial class AspireBlobStorageExtensions\n{\n    private sealed class BlobStorageComponent : AzureComponent<AzureStorageBlobsSettings, BlobServiceClient, BlobClientOptions>\n    {\n        protected override IAzureClientBuilder<BlobServiceClient, BlobClientOptions> AddClient(\n            AzureClientFactoryBuilder azureFactoryBuilder, AzureStorageBlobsSettings settings, string connectionName,\n            string configurationSectionName)\n        {\n            return ((IAzureClientFactoryBuilderWithCredential)azureFactoryBuilder).RegisterClientFactory<BlobServiceClient, BlobClientOptions>((options, cred) =>\n            {\n                var connectionString = settings.ConnectionString;\n                if (string.IsNullOrEmpty(connectionString) && settings.ServiceUri is null)\n                {\n                    throw new InvalidOperationException($\"A BlobServiceClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or specify a 'ConnectionString' or 'ServiceUri' in the '{configurationSectionName}' configuration section.\");\n                }\n\n                return !string.IsNullOrEmpty(connectionString) ? new BlobServiceClient(connectionString, options) :\n                    cred is not null ? new BlobServiceClient(settings.ServiceUri, cred, options) :\n                    new BlobServiceClient(settings.ServiceUri, options);\n            }, requiresCredential: false);\n        }\n\n        protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<BlobServiceClient, BlobClientOptions> clientBuilder, IConfiguration configuration)\n        {\n#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works\n            clientBuilder.ConfigureOptions(options => configuration.Bind(options));\n#pragma warning restore IDE0200\n        }\n\n        protected override void BindSettingsToConfiguration(AzureStorageBlobsSettings settings, IConfiguration configuration)\n        {\n            configuration.Bind(settings);","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.BlobStorageComponent.cs#L12-L48","documentation":"Aspire's Azure Blob Storage integration throws this when neither a ConnectionString nor a ServiceUri is configured for BlobServiceClient. The client requires one of the two to reach the storage account; the library validates this up-front and throws a descriptive InvalidOperationException instead of an SDK error.","triggerScenarios":"Calling builder.AddAzureBlobServiceClient(connectionName) where 'ConnectionStrings:<connectionName>' does not exist and 'Aspire:Azure:Storage:Blobs' has no ConnectionString or ServiceUri key.","commonSituations":"Connection name mismatch between the AppHost resource name and the AddAzureBlobServiceClient argument; running locally without user secrets; storage resource not referenced via WithReference so no connection string was injected.","solutions":["Add a connection string: \"ConnectionStrings\": { \"blobs\": \"<storage connection string>\" } or an endpoint-style value","Set ServiceUri in config: \"Aspire:Azure:Storage:Blobs\": { \"ServiceUri\": \"https://<account>.blob.core.windows.net/\" }","In the AppHost call builder.AddAzureBlobStorage(\"blobs\") and .WithReference(storage) in the project","Verify the connectionName string exactly matches the ConnectionStrings key"],"exampleFix":"// before\nbuilder.AddAzureBlobServiceClient(\"storage\"); // no 'storage' key in ConnectionStrings\n// after (AppHost)\nvar storage = builder.AddAzureStorage(\"storage\");\n// project: builder.AddAzureBlobServiceClient(\"storage\").WithReference(storage);","handlingStrategy":"validation","validationCode":"if (builder.Configuration.GetConnectionString(\"blobs\") is null &&\n    builder.Configuration[\"Aspire:Azure:Storage:Blobs:ServiceUri\"] is null)\n    throw new InvalidOperationException(\"Provide ConnectionStrings:blobs or a ServiceUri for Blob Storage.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use WithReference from the AppHost to inject connection strings","Match resource name to connectionName argument exactly","Keep user secrets in sync with the connection names used in code"],"tags":["azure","blob-storage","configuration","connection-string"],"backgroundTag":"missing-required-config-field","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"}