{"record":{"id":"5c54b42c606c4f6a","repo":"microsoft/aspire","slug":"app-service-does-not-support-resources-with-multiple","errorCode":null,"errorMessage":"App Service does not support resources with multiple external endpoints.","messagePattern":"App Service does not support resources with multiple external endpoints\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs","lineNumber":119,"sourceCode":"        }\n\n        // Only http/https are supported in App Service\n        var unsupportedEndpoints = resolvedEndpoints.Where(r => r.Endpoint.UriScheme is not (\"http\" or \"https\")).ToArray();\n        if (unsupportedEndpoints.Length > 0)\n        {\n            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.\");\n        }\n\n        // App Service supports only one target port\n        var targetPortEndpoints = resolvedEndpoints\n            .Where(r => r.Endpoint.IsExternal)\n            .Select(r => r.TargetPort.Value)\n            .Distinct()\n            .ToList();\n\n        if (targetPortEndpoints.Count > 1)\n        {\n            throw new NotSupportedException(\"App Service does not support resources with multiple external endpoints.\");\n        }\n\n        var preserveHttp = environmentContext.Environment.PreserveHttpEndpoints;\n\n        foreach (var resolved in resolvedEndpoints)\n        {\n            var endpoint = resolved.Endpoint;\n\n            if (!endpoint.IsExternal)\n            {\n                throw new NotSupportedException($\"The endpoint '{endpoint.Name}' on resource '{resource.Name}' is not external. App Service only supports external endpoints.\");\n            }\n\n            // By default, HTTP endpoints are upgraded to HTTPS in App Service\n            // If PreserveHttpEndpoints is true, keep the original scheme\n            var scheme = preserveHttp ? endpoint.UriScheme : \"https\";\n            var port = scheme is \"http\" ? 80 : 443;\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs#L101-L137","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Keep only one external endpoint per project published to App Service; remove WithExternalHttpEndpoints or external flags from secondary endpoints.","Consolidate the secondary service into the same port (route internally) or extract it into a separate project/resource.","Choose a non-AppService publish target (e.g. containers/AKS) if multiple external ports are required."],"exampleFix":"// before\napi.WithHttpEndpoint(port: 8080, name: \"http\").WithExternalHttpEndpoints();\napi.WithHttpEndpoint(port: 9090, name: \"admin\").WithExternalHttpEndpoints();\n// after\napi.WithHttpEndpoint(port: 8080, name: \"http\").WithExternalHttpEndpoints();\napi.WithHttpEndpoint(port: 9090, name: \"admin\"); // internal, not external","handlingStrategy":"validation","validationCode":"var externalPorts = project.Annotations.OfType<EndpointAnnotation>()\n    .Where(e => e.IsExternal).Select(e => e.TargetPort).Distinct().ToList();\nif (externalPorts.Count > 1)\n    throw new NotSupportedException(\"App Service allows at most one external endpoint target port per project.\");","typeGuard":null,"tryCatchPattern":"try { await environmentContext.ProcessAsync(); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"multiple external endpoints\"))\n{\n    logger.LogError(ex, \"Collapse to a single external endpoint or choose a container publish target.\");\n    throw;\n}","preventionTips":["Mark exactly one endpoint as external per App Service project.","Split multi-port services into separate projects or keep secondary endpoints internal.","Prefer container/AKS publishing when multiple public ports are required."],"tags":["azure-app-service","endpoint","port","validation"],"backgroundTag":"conflicting-config-options","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"}