{"record":{"id":"0a539b9a22ddf520","repo":"microsoft/aspire","slug":"a-blobserviceclient-could-not-be-configured-ensure-valid-0a539b","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.BlobStorageContainerComponent.cs","lineNumber":35,"sourceCode":"\npartial class AspireBlobStorageExtensions\n{\n    private sealed partial class BlobStorageContainerComponent : AzureComponent<AzureBlobStorageContainerSettings, BlobContainerClient, BlobClientOptions>\n    {\n        protected override IAzureClientBuilder<BlobContainerClient, BlobClientOptions> AddClient(\n            AzureClientFactoryBuilder azureFactoryBuilder, AzureBlobStorageContainerSettings settings, string connectionName, string configurationSectionName)\n        {\n            return ((IAzureClientFactoryBuilderWithCredential)azureFactoryBuilder).RegisterClientFactory<BlobContainerClient, BlobClientOptions>((options, cred) =>\n            {\n                if (string.IsNullOrEmpty(settings.BlobContainerName))\n                {\n                    throw new InvalidOperationException($\"The connection string '{connectionName}' does not exist or is missing the container name.\");\n                }\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                var blobServiceClient = !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\n                var containerClient = blobServiceClient.GetBlobContainerClient(settings.BlobContainerName);\n                return containerClient;\n            }, requiresCredential: false);\n        }\n\n        protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<BlobContainerClient, 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","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.BlobStorageContainerComponent.cs#L17-L53","documentation":"Same family as the BlobServiceClient error: after validating the container name, the BlobContainerComponent requires either ConnectionString or ServiceUri to build the underlying BlobServiceClient used to create the BlobContainerClient. Thrown when both are absent.","triggerScenarios":"Calling AddAzureBlobContainerClient with BlobContainerName set but no 'ConnectionStrings:<connectionName>' and no ConnectionString/ServiceUri in the 'Aspire:Azure:Storage:Blobs' section.","commonSituations":"Container name configured but connection info forgotten; WithReference missing in AppHost so no connection string injected; connection string key renamed.","solutions":["Add \"ConnectionStrings\": { \"<connectionName>\": \"<storage connection string>\" }","Set \"ServiceUri\": \"https://<account>.blob.core.windows.net/\" in the Aspire:Azure:Storage:Blobs section","Add .WithReference(storage) in the AppHost wiring so connection info is injected","Verify the connectionName argument matches the ConnectionStrings key"],"exampleFix":"// before\n\"Aspire:Azure:Storage:Blobs\": { \"ContainerName\": \"mycontainer\" } // no connection info\n// after\n\"Aspire:Azure:Storage:Blobs\": { \"ContainerName\": \"mycontainer\", \"ServiceUri\": \"https://acct.blob.core.windows.net/\" }","handlingStrategy":"validation","validationCode":"if (builder.Configuration.GetConnectionString(connectionName) is null &&\n    builder.Configuration[\"Aspire:Azure:Storage:Blobs:ServiceUri\"] is null)\n    throw new InvalidOperationException(\"Provide connection info before adding the blob container client.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure both ContainerName and connection info together","Verify WithReference wiring for the storage resource","Test startup config in each environment"],"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"}