microsoft/aspire · error · NotSupportedException

App Service does not support resources with multiple…

Error message

App Service does not support resources with multiple external endpoints.

What it means

App Service maps a website to a single site binding/target port, so the publish model requires that all external endpoints on a resource resolve to the same target port. ProcessEndpoints collects the distinct target ports of external endpoints and throws this NotSupportedException when there is more than one.

Solutions

  1. Keep only one external endpoint per project published to App Service; remove WithExternalHttpEndpoints or external flags from secondary endpoints.
  2. Consolidate the secondary service into the same port (route internally) or extract it into a separate project/resource.
  3. Choose a non-AppService publish target (e.g. containers/AKS) if multiple external ports are required.

Example fix

// before
api.WithHttpEndpoint(port: 8080, name: "http").WithExternalHttpEndpoints();
api.WithHttpEndpoint(port: 9090, name: "admin").WithExternalHttpEndpoints();
// after
api.WithHttpEndpoint(port: 8080, name: "http").WithExternalHttpEndpoints();
api.WithHttpEndpoint(port: 9090, name: "admin"); // internal, not external
Defensive patterns

Strategy: validation

Validate before calling

var externalPorts = project.Annotations.OfType<EndpointAnnotation>()
    .Where(e => e.IsExternal).Select(e => e.TargetPort).Distinct().ToList();
if (externalPorts.Count > 1)
    throw new NotSupportedException("App Service allows at most one external endpoint target port per project.");

Try / catch

try { await environmentContext.ProcessAsync(); }
catch (NotSupportedException ex) when (ex.Message.Contains("multiple external endpoints"))
{
    logger.LogError(ex, "Collapse to a single external endpoint or choose a container publish target.");
    throw;
}

Prevention

When it happens

Trigger: Publishing a project to App Service that declares two or more external endpoints with different target ports, e.g. WithEndpoint("http", port 8080, isExternal) plus WithEndpoint("admin", port 9090, isExternal).

Common situations: Monolith projects exposing multiple HTTP services on distinct ports that worked in local app-host mode; migrating a multi-port project from container/compute publishing to App Service; accidentally marking secondary endpoints as external.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs:119

        }

        // Only http/https are supported in App Service
        var unsupportedEndpoints = resolvedEndpoints.Where(r => r.Endpoint.UriScheme is not ("http" or "https")).ToArray();
        if (unsupportedEndpoints.Length > 0)
        {
            throw new NotSupportedException($"The endpoint(s) {string.Join(", ", unsupportedEndpoints.Select(r => $"'{r.Endpoint.Name}'"))} on resource '{resource.Name}' specifies an unsupported scheme. Only http and https are supported in App Service.");
        }

        // App Service supports only one target port
        var targetPortEndpoints = resolvedEndpoints
            .Where(r => r.Endpoint.IsExternal)
            .Select(r => r.TargetPort.Value)
            .Distinct()
            .ToList();

        if (targetPortEndpoints.Count > 1)
        {
            throw new NotSupportedException("App Service does not support resources with multiple external endpoints.");
        }

        var preserveHttp = environmentContext.Environment.PreserveHttpEndpoints;

        foreach (var resolved in resolvedEndpoints)
        {
            var endpoint = resolved.Endpoint;

            if (!endpoint.IsExternal)
            {
                throw new NotSupportedException($"The endpoint '{endpoint.Name}' on resource '{resource.Name}' is not external. App Service only supports external endpoints.");
            }

            // By default, HTTP endpoints are upgraded to HTTPS in App Service
            // If PreserveHttpEndpoints is true, keep the original scheme
            var scheme = preserveHttp ? endpoint.UriScheme : "https";
            var port = scheme is "http" ? 80 : 443;

View on GitHub (pinned to 25830f84bd)