{"record":{"id":"0ea79a711e3874dc","repo":"microsoft/aspire","slug":"a-queueserviceclient-could-not-be-configured-ensure-valid","errorCode":null,"errorMessage":"A QueueServiceClient 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 QueueServiceClient 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.Queues/AspireQueueStorageExtensions.cs","lineNumber":192,"sourceCode":"    {\n        ArgumentNullException.ThrowIfNull(builder);\n        ArgumentException.ThrowIfNullOrEmpty(name);\n\n        new StorageQueueComponent().AddClient(builder, DefaultConfigSectionName, configureSettings, configureClientBuilder, connectionName: name, serviceKey: name);\n    }\n\n    private sealed class StorageQueuesComponent : AzureComponent<AzureStorageQueuesSettings, QueueServiceClient, QueueClientOptions>\n    {\n        protected override IAzureClientBuilder<QueueServiceClient, QueueClientOptions> AddClient(\n            AzureClientFactoryBuilder azureFactoryBuilder, AzureStorageQueuesSettings settings, string connectionName,\n            string configurationSectionName)\n        {\n            return ((IAzureClientFactoryBuilderWithCredential)azureFactoryBuilder).RegisterClientFactory<QueueServiceClient, QueueClientOptions>((options, cred) =>\n            {\n                var connectionString = settings.ConnectionString;\n                if (string.IsNullOrEmpty(connectionString) && settings.ServiceUri is null)\n                {\n                    throw new InvalidOperationException($\"A QueueServiceClient 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)\n                    ? new QueueServiceClient(connectionString, options)\n                    : cred is not null\n                        ? new QueueServiceClient(settings.ServiceUri, cred, options)\n                        : new QueueServiceClient(settings.ServiceUri, options);\n            }, requiresCredential: false);\n        }\n\n        protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<QueueServiceClient, QueueClientOptions> 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(AzureStorageQueuesSettings settings, IConfiguration configuration)","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L174-L210","documentation":"Aspire's Azure Storage Queues client registration requires a way to construct a QueueServiceClient. This error is thrown when, at service resolution time, neither a connection string nor a ServiceUri was resolved from the connection name or the component's configuration section, so no client can be created.","triggerScenarios":"Calling AddAzureQueues/AddKeyedAzureQueues with a connectionName that has no 'ConnectionStrings:{connectionName}' entry and no 'ConnectionString' or 'ServiceUri' key in the '{configurationSectionName}' config section (e.g. Aspire:Azure:Storage:Queues).","commonSituations":"Connection string not set in appsettings.json or user secrets; running outside Aspire AppHost without connection-string injection; typo in connection name; using a keyed variant with a name that was never registered; config section renamed after a package upgrade.","solutions":["Add a 'ConnectionStrings:{connectionName}' value (storage account connection string or service URI) to appsettings.json or user secrets.","If running under the Aspire AppHost, ensure the project references the Azure Storage Queues hosting resource so the connection is injected at run time.","Alternatively set 'ConnectionString' or 'ServiceUri' under the 'Aspire:Azure:Storage:Queues' configuration section.","Verify the connectionName passed to AddAzureQueues matches the configured key exactly (case-sensitive lookup)."],"exampleFix":"// before\nbuilder.AddAzureQueuesClient(\"queues\"); // no 'queues' connection defined\n// after (appsettings.json)\n// { \"ConnectionStrings\": { \"queues\": \"https://mystorageaccount.queue.core.windows.net/\" } }\nbuilder.AddAzureQueuesClient(\"queues\");","handlingStrategy":"validation","validationCode":"var cs = builder.Configuration.GetConnectionString(\"queues\");\nvar section = builder.Configuration.GetSection(\"Aspire:Azure:Storage:Queues\");\nif (string.IsNullOrEmpty(cs) && section[\"ServiceUri\"] is null && section[\"ConnectionString\"] is null)\n    throw new InvalidOperationException(\"Configure ConnectionStrings:queues or Aspire:Azure:Storage:Queues before calling AddAzureQueuesClient.\");","typeGuard":null,"tryCatchPattern":"try { /* first resolve of QueueServiceClient */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"QueueServiceClient could not be configured\"))\n{\n    logger.LogError(ex, \"Azure Storage Queues connection info missing; check ConnectionStrings:queues.\");\n    throw;\n}","preventionTips":["Register storage resources in the AppHost and use WithReference so connection strings are injected automatically.","Keep connection names consistent between AppHost and consuming project.","Add a startup config sanity check in non-Aspire environments.","Store local overrides in user secrets, not appsettings.json."],"tags":["azure","configuration","connection-string","dependency-injection"],"backgroundTag":"missing-required-config","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"}