microsoft/aspire · error · InvalidOperationException

An EventProcessorClient could not be configured. Ensure a…

Error message

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.

What it means

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.

Solutions

  1. Register a BlobServiceClient by calling builder.AddAzureBlobClient("blobs") (or AddKeyedAzureBlobClient) in the same application before AddAzureEventProcessorClient.
  2. If the BlobServiceClient is keyed, set BlobClientServiceKey in the '{configurationSectionName}' config section or via the settings callback so the processor can resolve it.
  3. Alternatively register a plain BlobServiceClient in DI manually for local/test scenarios.
  4. Ensure the settings callback / config section name used for BlobClientServiceKey matches the key used at registration.

Example fix

// before
builder.AddAzureEventProcessorClient("eh", settings => { settings.EventHubName = "orders"; settings.BlobContainerName = "checkpoints"; }); // no BlobServiceClient in DI
// after
builder.AddAzureBlobClient("checkpoints");
builder.AddAzureEventProcessorClient("eh", settings => { settings.EventHubName = "orders"; settings.BlobContainerName = "checkpoints"; });
Defensive patterns

Strategy: validation

Validate before calling

using var scope = app.Services.CreateScope();
var keyed = scope.ServiceProvider.GetKeyedService<BlobServiceClient>(app.Configuration["EventHubs:BlobClientServiceKey"]);
var plain = scope.ServiceProvider.GetService<BlobServiceClient>();
if (keyed is null && plain is null)
    throw new InvalidOperationException("Register a BlobServiceClient (AddAzureBlobClient) for EventProcessorClient checkpoints.");

Type guard

bool blobClientAvailable = serviceProvider.GetService<BlobServiceClient>() is not null || serviceProvider.GetKeyedService<BlobServiceClient>(settings.BlobClientServiceKey) is not null;

Try / catch

try { processorClient = serviceProvider.GetRequiredService<EventProcessorClient>(); } catch (InvalidOperationException ex) when (ex.Message.Contains("BlobServiceClient")) { logger.LogError(ex, "BlobServiceClient not registered for checkpointing"); throw; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/8108faa921235cb7. Report an issue: GitHub.

Appendix: source

Thrown at src/Components/Aspire.Azure.Messaging.EventHubs/EventProcessorClientComponent.cs:84

                return new EventProcessorClient(containerClient,
                    consumerGroup,
                    settings.ConnectionString,
                    settings.EventHubName, options);

            });
    }

    private static BlobContainerClient GetBlobContainerClient(
        AzureMessagingEventHubsProcessorSettings settings, IServiceProvider provider, string configurationSectionName)
    {
        // look for keyed client if one is configured. Otherwise, get an unkeyed BlobServiceClient
        var blobClient = !string.IsNullOrEmpty(settings.BlobClientServiceKey) ?
            provider.GetKeyedService<BlobServiceClient>(settings.BlobClientServiceKey) :
            provider.GetService<BlobServiceClient>();

        if (blobClient is null)
        {
            throw new InvalidOperationException(
                $"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.");
        }

        // consumer group and blob container names have similar constraints (alphanumeric, hyphen) but we should sanitize nonetheless
        var consumerGroup = (string.IsNullOrWhiteSpace(settings.ConsumerGroup)) ? "default" : settings.ConsumerGroup;

        // Only attempt to create a container if it was NOT found in the connection string
        // this is always the case for an Aspire mounted blob resource, but a dev could provide a blob
        // connection string themselves that includes a container name in the Uri already; in this case
        // we assume it already exists and avoid the extra permission demand. The applies to any container
        // name specified in the settings.
        bool shouldTryCreateIfNotExists = false;

        // Do we have a container name provided in the settings?
        if (string.IsNullOrWhiteSpace(settings.BlobContainerName))
        {

View on GitHub (pinned to 25830f84bd)