{"record":{"id":"d8b4e1602d67f50a","repo":"microsoft/aspire","slug":"a-queueclient-could-not-be-configured-ensure-valid","errorCode":null,"errorMessage":"A QueueClient 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 QueueClient 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":246,"sourceCode":"            => !settings.DisableTracing;\n    }\n\n    private sealed partial class StorageQueueComponent : AzureComponent<AzureStorageQueueSettings, QueueClient, QueueClientOptions>\n    {\n        protected override IAzureClientBuilder<QueueClient, QueueClientOptions> AddClient(\n            AzureClientFactoryBuilder azureFactoryBuilder, AzureStorageQueueSettings settings, string connectionName, string configurationSectionName)\n        {\n            return ((IAzureClientFactoryBuilderWithCredential)azureFactoryBuilder).RegisterClientFactory<QueueClient, QueueClientOptions>((options, cred) =>\n            {\n                if (string.IsNullOrEmpty(settings.QueueName))\n                {\n                    throw new InvalidOperationException($\"The connection string '{connectionName}' does not exist or is missing the queue name.\");\n                }\n\n                var connectionString = settings.ConnectionString;\n                if (string.IsNullOrEmpty(connectionString) && settings.ServiceUri is null)\n                {\n                    throw new InvalidOperationException($\"A QueueClient 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 queueServiceClient = !string.IsNullOrEmpty(connectionString) ? new QueueServiceClient(connectionString, options) :\n                    cred is not null ? new QueueServiceClient(settings.ServiceUri, cred, options) :\n                    new QueueServiceClient(settings.ServiceUri, options);\n\n                var client = queueServiceClient.GetQueueClient(settings.QueueName);\n                return client;\n            }, requiresCredential: false);\n        }\n\n        protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<QueueClient, 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","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L228-L264","documentation":"Like the QueueServiceClient variant, this is thrown when a QueueClient cannot be constructed because neither a connection string nor a ServiceUri was provided. It fires only after the queue-name check passes, so the queue name was configured but no endpoint/connection information resolved.","triggerScenarios":"Calling AddAzureQueueClient with a valid QueueName (or queue-bearing connection) but 'ConnectionStrings:{connectionName}' missing and no 'ConnectionString'/'ServiceUri' in the '{configurationSectionName}' config section.","commonSituations":"Queue name set in the Aspire:Azure:Storage:Queues section but connection string forgotten; running without the AppHost-provided connection; key typo in ConnectionStrings; config not loaded (wrong environment).","solutions":["Add 'ConnectionStrings:{connectionName}' with the storage account connection string or service URI in appsettings.json or user secrets.","Run the app under the Aspire AppHost so the connection string is injected automatically.","Set 'ServiceUri' (e.g. https://account.queue.core.windows.net) under the 'Aspire:Azure:Storage:Queues' config section.","Verify config is actually loaded (correct appsettings.{Environment}.json, secrets initialized)."],"exampleFix":"// before\nbuilder.AddAzureQueueClient(\"queues\"); // QueueName set, but no connection\n// after\n// appsettings.json: \"ConnectionStrings\": { \"queues\": \"DefaultEndpointsProtocol=https;AccountName=acct;AccountKey=...\" }\nbuilder.AddAzureQueueClient(\"queues\");","handlingStrategy":"validation","validationCode":"var hasConnection = !string.IsNullOrEmpty(builder.Configuration.GetConnectionString(\"queues\"));\nvar serviceUri = builder.Configuration[\"Aspire:Azure:Storage:Queues:ServiceUri\"];\nif (!hasConnection && string.IsNullOrEmpty(serviceUri))\n    throw new InvalidOperationException(\"Provide ConnectionStrings:queues or Aspire:Azure:Storage:Queues:ServiceUri.\");","typeGuard":null,"tryCatchPattern":"try { /* resolve QueueClient */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"A QueueClient could not be configured\"))\n{\n    logger.LogError(ex, \"Missing queue connection info for 'queues'.\");\n    throw;\n}","preventionTips":["Verify both QueueName and connection info are configured when using AddAzureQueueClient.","Run through the AppHost during local development to catch missing injected connections early.","Add a health check against the queue client at startup."],"tags":["azure","configuration","connection-string","queue"],"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-21T09:17:21.228Z"}