microsoft/aspire · error · DistributedApplicationException
was published for the ' ' resource but the connection…
Error message
{nameof(ConnectionStringAvailableEvent)} was published for the '{builder.Resource.Name}' resource but the connection string was null. What it means
In RunAsEmulator's OnBeforeResourceStarted handler, the blob connection string is resolved asynchronously; if it resolves to null the code throws DistributedApplicationException referencing ConnectionStringAvailableEvent. This is an internal invariant: without a connection string the emulator's BlobServiceClient cannot be created.
Solutions
- Check the emulator container started correctly and its endpoint was published
- Re-run with updated Aspire packages; if it persists, file an issue (this indicates an internal invariant failure)
- Verify RunAsEmulator configuration (port assignments, proxy settings) is unchanged
Defensive patterns
Strategy: try-catch
Validate before calling
var cs = await storage.Resource.GetBlobConnectionString().GetValueAsync(ct);
if (cs is null) { logger.LogError("Blob connection string missing for {Name}", storage.Resource.Name); return; } Try / catch
try { await startWorkflow(ct); }
catch (DistributedApplicationException ex) { logger.LogError(ex, "Emulator connection string invariant failed"); throw; } Prevention
- Keep RunAsEmulator wiring on current Aspire versions
- Do not remove lifecycle hooks that initialize emulator clients
- Verify emulator endpoints publish before resource start
When it happens
Trigger: Resource start of an emulated Azure Storage resource where GetBlobConnectionString().GetValueAsync returns null (connection string expression produced no value).
Common situations: Emulator endpoint/proxy not correctly configured, misconfigured emulator settings, or internal wiring regression causing a missing connection string at startup.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- is not initialized.
- Emulator currently does not support data lake.
- Emulator currently does not support data lake.
- A BlobServiceClient could not be configured. Ensure valid…
- A BlobServiceClient could not be configured. Ensure valid…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/c5ae66056bbd287b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs:218
.WithHttpEndpoint(name: "table", targetPort: 10002)
.WithAnnotation(new ContainerImageAnnotation
{
Registry = StorageEmulatorContainerImageTags.Registry,
Image = StorageEmulatorContainerImageTags.Image,
Tag = StorageEmulatorContainerImageTags.Tag
});
BlobServiceClient? blobServiceClient = null;
QueueServiceClient? queueServiceClient = null;
builder
.OnBeforeResourceStarted(async (storage, @event, ct) =>
{
// The BlobServiceClient and QueueServiceClient are created before the health check is run.
// We can't use ConnectionStringAvailableEvent here because the resource doesn't have a connection string, so
// we use BeforeResourceStartedEvent
var blobConnectionString = await builder.Resource.GetBlobConnectionString().GetValueAsync(ct).ConfigureAwait(false) ?? throw new DistributedApplicationException($"{nameof(ConnectionStringAvailableEvent)} was published for the '{builder.Resource.Name}' resource but the connection string was null.");
blobServiceClient = CreateBlobServiceClient(blobConnectionString);
var queueConnectionString = await builder.Resource.GetQueueConnectionString().GetValueAsync(ct).ConfigureAwait(false) ?? throw new DistributedApplicationException($"{nameof(ConnectionStringAvailableEvent)} was published for the '{builder.Resource.Name}' resource but the connection string was null.");
queueServiceClient = CreateQueueServiceClient(queueConnectionString);
})
.OnResourceReady(async (storage, @event, ct) =>
{
// The ResourceReadyEvent of a resource is triggered after its health check (AddAzureBlobStorage) is healthy.
// This means we can safely use this event to create the blob containers.
_ = blobServiceClient ?? throw new InvalidOperationException($"{nameof(BlobServiceClient)} is not initialized.");
_ = queueServiceClient ?? throw new InvalidOperationException($"{nameof(QueueServiceClient)} is not initialized.");
foreach (var container in builder.Resource.BlobContainers)
{
var blobContainerClient = blobServiceClient.GetBlobContainerClient(container.BlobContainerName);
await blobContainerClient.CreateIfNotExistsAsync(cancellationToken: ct).ConfigureAwait(false);
}View on GitHub (pinned to 25830f84bd)