microsoft/aspire · error · InvalidOperationException
Azure resource ' ' is missing required output ' '. Ensure…
Error message
Azure resource '{resource.Name}' is missing required output '{name}'. Ensure Azure infrastructure provisioning completed successfully. What it means
Thrown by GetRequiredOutput when an AzureBicepResource's Outputs dictionary does not contain the requested key, the value is null, or its string form is blank. The library relies on Bicep deployment outputs to wire sandbox resources together and treats a missing output as a provisioning failure.
Solutions
- Ensure the Azure infrastructure provisioning completed successfully before consuming outputs; check provisioning logs for errors.
- Confirm the Bicep module actually declares the required `output` with the exact name requested.
- Re-run the deployment to repopulate outputs if the previous run failed.
- Verify the AzureBicepResource instance is the one that was deployed, not a stand-in/placeholder resource.
Example fix
// before: bicep module without output
resource sandboxGroup '...' = { ... }
// after: declare the output
output id string = sandboxGroup.id Defensive patterns
Strategy: validation
Validate before calling
bool HasOutput(AzureBicepResource r, string name) =>
r.Outputs.TryGetValue(name, out var v) && v is not null && !string.IsNullOrWhiteSpace(v.ToString()); Try / catch
try { var id = GetRequiredOutput(resource, "id"); }
catch (InvalidOperationException ex) { logger.LogError(ex, "Provisioning output missing on {Resource}", resource.Name); throw; } Prevention
- Declare every consumed output in the Bicep module.
- Gate consumption on successful provisioning completion.
- Keep Bicep output names in sync with GetRequiredOutput call sites.
When it happens
Trigger: GetRequiredOutput(resource, "id") (or similar) on an AzureBicepResource whose Outputs collection lacks the named output — e.g. the resource was never provisioned, provisioning failed partway, or the Bicep module does not declare the output.
Common situations: Running against a resource whose `azd`/ARM deployment never completed; referencing an output renamed in a newer Bicep template; the AppHost started without the infrastructure provisioning phase having run.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- A of type cannot be assigned to a BicepValue< >.
- An Azure principal parameter was not supplied a value…
- AzureEnvironmentResource must be present in the application…
- Deployment failed
- Expected a string, integer, or
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/c6692d680719e8a4.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:2317
}
}
private static string GetRequiredStateValue(DeploymentStateSection section, string name)
{
var value = section.Data[name]?.GetValue<string>();
if (string.IsNullOrWhiteSpace(value))
{
throw new InvalidOperationException($"Deployment state section '{section.SectionName}' is missing required value '{name}'.");
}
return value;
}
private static string GetRequiredOutput(AzureBicepResource resource, string name)
{
if (!resource.Outputs.TryGetValue(name, out var value) || value is null || string.IsNullOrWhiteSpace(value.ToString()))
{
throw new InvalidOperationException($"Azure resource '{resource.Name}' is missing required output '{name}'. Ensure Azure infrastructure provisioning completed successfully.");
}
return value.ToString()!;
}
internal static AzureDevComputeResourceScope CreateDataPlaneScope(AzureSandboxGroupResource sandboxGroup)
{
ArgumentNullException.ThrowIfNull(sandboxGroup);
var resourceId = new global::Azure.Core.ResourceIdentifier(GetRequiredOutput(sandboxGroup, "id"));
if (string.IsNullOrWhiteSpace(resourceId.SubscriptionId) ||
string.IsNullOrWhiteSpace(resourceId.ResourceGroupName) ||
string.IsNullOrWhiteSpace(resourceId.Name))
{
throw new InvalidOperationException(
$"Azure sandbox group '{sandboxGroup.Name}' returned an invalid resource ID '{resourceId}'.");
}
View on GitHub (pinned to 25830f84bd)