{"record":{"id":"8108faa921235cb7","repo":"microsoft/aspire","slug":"an-eventprocessorclient-could-not-be-configured-ensure-a","errorCode":null,"errorMessage":"An EventProcessorClient could not be configured. Ensure a valid 'BlobServiceClient' is available in the ServiceProvider or provide the service key of the 'BlobServiceClient' in the '{configurationSectionName}:BlobClientServiceKey' configuration section, or use the settings callback to configure it in code.","messagePattern":"An EventProcessorClient could not be configured\\. Ensure a valid 'BlobServiceClient' is available in the ServiceProvider or provide the service key of the 'BlobServiceClient' in the '(.+?):BlobClientServiceKey' configuration section, or use the settings callback to configure it in code\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Aspire.Azure.Messaging.EventHubs/EventProcessorClientComponent.cs","lineNumber":84,"sourceCode":"                return new EventProcessorClient(containerClient,\n                    consumerGroup,\n                    settings.ConnectionString,\n                    settings.EventHubName, options);\n\n            });\n    }\n\n    private static BlobContainerClient GetBlobContainerClient(\n        AzureMessagingEventHubsProcessorSettings settings, IServiceProvider provider, string configurationSectionName)\n    {\n        // look for keyed client if one is configured. Otherwise, get an unkeyed BlobServiceClient\n        var blobClient = !string.IsNullOrEmpty(settings.BlobClientServiceKey) ?\n            provider.GetKeyedService<BlobServiceClient>(settings.BlobClientServiceKey) :\n            provider.GetService<BlobServiceClient>();\n\n        if (blobClient is null)\n        {\n            throw new InvalidOperationException(\n                $\"An EventProcessorClient could not be configured. Ensure a valid 'BlobServiceClient' is available in the ServiceProvider or \" +\n                $\"provide the service key of the 'BlobServiceClient' in \" +\n                $\"the '{configurationSectionName}:BlobClientServiceKey' configuration section, or use the settings callback to configure it in code.\");\n        }\n\n        // consumer group and blob container names have similar constraints (alphanumeric, hyphen) but we should sanitize nonetheless\n        var consumerGroup = (string.IsNullOrWhiteSpace(settings.ConsumerGroup)) ? \"default\" : settings.ConsumerGroup;\n\n        // Only attempt to create a container if it was NOT found in the connection string\n        // this is always the case for an Aspire mounted blob resource, but a dev could provide a blob\n        // connection string themselves that includes a container name in the Uri already; in this case\n        // we assume it already exists and avoid the extra permission demand. The applies to any container\n        // name specified in the settings.\n        bool shouldTryCreateIfNotExists = false;\n\n        // Do we have a container name provided in the settings?\n        if (string.IsNullOrWhiteSpace(settings.BlobContainerName))\n        {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Azure.Messaging.EventHubs/EventProcessorClientComponent.cs#L66-L102","documentation":"EventProcessorClient persists checkpoints in Azure Blob Storage, so Aspire requires a BlobServiceClient to create a BlobContainerClient. It resolves it from DI (keyed via '{configurationSectionName}:BlobClientServiceKey' or unkeyed). If neither a keyed nor a default BlobServiceClient is registered, the processor cannot manage checkpoints and throws.","triggerScenarios":"AddAzureEventProcessorClient's GetBlobContainerClient (via containerClient) resolving the service provider: settings.BlobClientServiceKey is set but no keyed BlobServiceClient exists, or BlobClientServiceKey is empty and no default BlobServiceClient is registered in DI.","commonSituations":"Using the EventHubs component without also registering the Blob Storage component (AddAzureBlobClient) so no BlobServiceClient exists; registering BlobServiceClient with a key but not setting BlobClientServiceKey (or vice versa); removing the Blob registration during refactoring; running with a DI container missing the Aspire blob client factory output.","solutions":["Register a BlobServiceClient by calling builder.AddAzureBlobClient(\"blobs\") (or AddKeyedAzureBlobClient) in the same application before AddAzureEventProcessorClient.","If the BlobServiceClient is keyed, set BlobClientServiceKey in the '{configurationSectionName}' config section or via the settings callback so the processor can resolve it.","Alternatively register a plain BlobServiceClient in DI manually for local/test scenarios.","Ensure the settings callback / config section name used for BlobClientServiceKey matches the key used at registration."],"exampleFix":"// before\nbuilder.AddAzureEventProcessorClient(\"eh\", settings => { settings.EventHubName = \"orders\"; settings.BlobContainerName = \"checkpoints\"; }); // no BlobServiceClient in DI\n// after\nbuilder.AddAzureBlobClient(\"checkpoints\");\nbuilder.AddAzureEventProcessorClient(\"eh\", settings => { settings.EventHubName = \"orders\"; settings.BlobContainerName = \"checkpoints\"; });","handlingStrategy":"validation","validationCode":"using var scope = app.Services.CreateScope();\nvar keyed = scope.ServiceProvider.GetKeyedService<BlobServiceClient>(app.Configuration[\"EventHubs:BlobClientServiceKey\"]);\nvar plain = scope.ServiceProvider.GetService<BlobServiceClient>();\nif (keyed is null && plain is null)\n    throw new InvalidOperationException(\"Register a BlobServiceClient (AddAzureBlobClient) for EventProcessorClient checkpoints.\");","typeGuard":"bool blobClientAvailable = serviceProvider.GetService<BlobServiceClient>() is not null || serviceProvider.GetKeyedService<BlobServiceClient>(settings.BlobClientServiceKey) is not null;","tryCatchPattern":"try { processorClient = serviceProvider.GetRequiredService<EventProcessorClient>(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"BlobServiceClient\")) { logger.LogError(ex, \"BlobServiceClient not registered for checkpointing\"); throw; }","preventionTips":["Register AddAzureBlobClient whenever you use AddAzureEventProcessorClient","Keep BlobClientServiceKey in sync with the keyed blob client registration","Add an integration test that resolves EventProcessorClient from the DI container","Use keyed services consistently: either all keyed or all default"],"tags":["azure","event-hubs","dependency-injection","blob-storage"],"backgroundTag":"missing-dependency","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"}