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

  1. Ensure the Azure infrastructure provisioning completed successfully before consuming outputs; check provisioning logs for errors.
  2. Confirm the Bicep module actually declares the required `output` with the exact name requested.
  3. Re-run the deployment to repopulate outputs if the previous run failed.
  4. 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

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


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)