microsoft/aspire · error · InvalidOperationException
The configuration file mount could not be parsed.
Error message
The configuration file mount could not be parsed.
What it means
When RunAsEmulator builds the emulator's Config.json, it parses the generated JSON with JsonNode.Parse and throws InvalidOperationException if the result is null (i.e. the string represented only JSON null or whitespace). This is an internal invariant: CreateEmulatorConfigJson should always produce a parseable object, so a null parse means the mount content could not be produced.
Solutions
- Update Aspire.Hosting.Azure.ServiceBus to the latest version, since this indicates the generated config template is broken.
- Check whether any WithConfigJson-like annotations or custom code altered the configuration pipeline and remove the interference.
- Rebuild/clean your AppHost and re-restore packages to repair a corrupted install.
- If reproducible, file an issue with the AppHost code that triggers it — this exception is not expected in normal use.
Example fix
// before (suspected custom mutation corrupting config)
sb.RunAsEmulator(e => e.WithConfigJson("null"));
// after
sb.RunAsEmulator(e => e.WithConfigJson(configBuilder => { /* valid JSON object */ })); Defensive patterns
Strategy: try-catch
Try / catch
try
{
sb.RunAsEmulator();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("configuration file mount could not be parsed"))
{
// remove custom config mutations / WithConfigJson annotations, or update package, then retry
} Prevention
- Keep custom emulator config JSON a valid object (never "null" or empty).
- Update Aspire.Hosting.Azure.ServiceBus if this fires — the generated template should always parse.
- Remove conflicting ConfigJson annotations/hooks when debugging this error.
- Clean/rebuild to rule out corrupted package content.
When it happens
Trigger: Calling RunAsEmulator when JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource)) returns null — the generated default config string is effectively empty or the literal null.
Common situations: Modified or broken custom config generation (e.g. extensions/hooks that overwrite the config source); corrupted package install where the template content is missing; very rare framework bug.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- innerResource
- The Azure Service Bus resource is already configured to run…
- Dashboard endpoint is only available when running as an…
- Emulator currently does not support data lake.
- Emulator currently does not support data lake.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/e49efbed889df013.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs:484
{
var customConfigFile = builder.Resource.Annotations.OfType<ConfigFileAnnotation>().FirstOrDefault();
if (customConfigFile != null)
{
return Task.FromResult<IEnumerable<ContainerFileSystemItem>>([
new ContainerFile
{
Name = AzureServiceBusEmulatorResource.EmulatorConfigJsonFile,
SourcePath = customConfigFile.SourcePath,
},
]);
}
// Create default Config.json file content
var tempConfig = JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource));
if (tempConfig == null)
{
throw new InvalidOperationException("The configuration file mount could not be parsed.");
}
// Apply ConfigJsonAnnotation modifications
var configJsonAnnotations = builder.Resource.Annotations.OfType<ConfigJsonAnnotation>();
if (configJsonAnnotations.Any())
{
foreach (var annotation in configJsonAnnotations)
{
annotation.Configure(tempConfig);
}
}
using var writeStream = new MemoryStream();
using var writer = new Utf8JsonWriter(writeStream, new JsonWriterOptions { Indented = true });
tempConfig.WriteTo(writer);
writer.Flush();View on GitHub (pinned to 25830f84bd)