{"record":{"id":"744fa905b373143b","repo":"microsoft/aspire","slug":"multiple-external-endpoints-are-not-supported","errorCode":null,"errorMessage":"Multiple external endpoints are not supported","messagePattern":"Multiple external endpoints are not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs","lineNumber":173,"sourceCode":"            .GroupBy(x => x.resolved.TargetPort.Value)\n            .Select(g => new\n            {\n                Port = g.Key,\n                ResolvedEndpoints = g.Select(x => x.resolved).ToArray(),\n                External = g.Any(x => x.resolved.Endpoint.IsExternal),\n                IsHttpOnly = g.All(x => x.resolved.Endpoint.Transport is \"http\" or \"http2\"),\n                AnyH2 = g.Any(x => x.resolved.Endpoint.Transport is \"http2\"),\n                UniqueTransports = g.Select(x => x.resolved.Endpoint.Transport).Distinct().ToArray(),\n                Index = g.Min(x => x.index)\n            })\n            .ToList();\n\n        // Failure cases\n\n        // Multiple external endpoints are not supported\n        if (endpointsByTargetPort.Count(g => g.External) > 1)\n        {\n            throw new NotSupportedException(\"Multiple external endpoints are not supported\");\n        }\n\n        // Any external non-http endpoints are not supported\n        if (endpointsByTargetPort.Any(g => g.External && !g.IsHttpOnly))\n        {\n            throw new NotSupportedException(\"External non-HTTP(s) endpoints are not supported\");\n        }\n\n        // Don't allow mixing http and tcp transports on the same target port\n        static bool Compatible(string[] transports) =>\n            transports.All(t => t is \"http\" or \"http2\") || transports.All(t => t is \"tcp\");\n\n        if (endpointsByTargetPort.Any(g => !Compatible(g.UniqueTransports)))\n        {\n            throw new NotSupportedException(\"HTTP(s) and TCP endpoints cannot be mixed\");\n        }\n\n        // Get all http only groups","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs#L155-L191","documentation":"A Container App can expose at most one external ingress endpoint. During endpoint processing Aspire groups endpoints by target port; if more than one group (or endpoint) is marked External, it throws this NotSupportedException. Keep a single external endpoint and expose additional services internally.","triggerScenarios":"Marking two or more endpoints as external (WithEndpoint(..., isExternal: true), WithHttpEndpoint(isExternal: true), or external: true) on the same resource published to Container Apps.","commonSituations":"Exposing both an HTTP API and a metrics/health UI publicly on one app; migrating from Kubernetes (multiple external Services) where Container Apps' single-ingress model is stricter.","solutions":["Mark only one endpoint as external; make the rest internal (isExternal: false).","Split the service into two projects/resources if both need separate public exposure.","Front additional routes through the single external ingress (path-based routing)."],"exampleFix":"// before\n.WithHttpEndpoint(port: 8080, name: \"http\", isExternal: true)\n.WithHttpEndpoint(port: 9090, name: \"metrics\", isExternal: true)\n\n// after\n.WithHttpEndpoint(port: 8080, name: \"http\", isExternal: true)\n.WithHttpEndpoint(port: 9090, name: \"metrics\", isExternal: false)","handlingStrategy":"validation","validationCode":"var externalCount = resource.GetEndpoints().Count(e => e.Endpoint.IsExternal);\nif (externalCount > 1) throw new InvalidOperationException(\"Container Apps allow only one external endpoint.\");","typeGuard":"bool HasSingleExternalEndpoint(IResource r) => r.Annotations.OfType<EndpointAnnotation>().Count(a => a.IsExternal) <= 1;","tryCatchPattern":"try { /* build/publish */ } catch (NotSupportedException ex) when (ex.Message == \"Multiple external endpoints are not supported\") { /* demote extra endpoints to internal */ }","preventionTips":["Design each container app around a single public ingress endpoint.","Expose auxiliary ports (metrics, admin) as internal only.","Use path-based routing on the one external endpoint for multiple routes."],"tags":["azure","container-apps","endpoints","ingress"],"backgroundTag":"invalid-argument-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}