microsoft/aspire · error · NotSupportedException

Endpoint ' ' on resource ' ' shares target port with…

Error message

Endpoint '{resolvedEndpoint.Endpoint.Name}' on resource '{resource.TargetResource.Name}' shares target port {resolvedTargetPort} with endpoint '{existingEndpoint.Name}' but uses a different transport. Azure sandbox ports support a single HTTP protocol per target port.

What it means

Each Azure sandbox target port maps to a single ingress protocol. If two endpoints share the same target port but declare different transports (e.g. http vs http2), the sandbox cannot represent both, so NotSupportedException is thrown.

Solutions

  1. Make both endpoints use the same transport for the shared target port
  2. Move one endpoint to a different target port
  3. Remove the redundant endpoint

Example fix

// before
.WithHttpEndpoint(targetPort: 8080)
.WithEndpoint(scheme: "http", transport: "http2", targetPort: 8080)
// after
.WithHttpEndpoint(targetPort: 8080)
.WithHttpEndpoint(targetPort: 8081)
Defensive patterns

Strategy: validation

Validate before calling

var byPort = resource.Endpoints.GroupBy(e => e.TargetPort)
    .Where(g => g.Select(e => e.Transport).Distinct().Count() > 1);
if (byPort.Any()) throw new InvalidOperationException("Shared target port with mixed transports.");

Try / catch

try { DeploySandbox(...); } catch (NotSupportedException ex) when (ex.Message.Contains("single HTTP protocol per target port")) { /* unify transports or split ports */ }

Prevention

When it happens

Trigger: Two EndpointAnnotations on resources in the sandbox resolve to the same resolvedTargetPort key but their resolved protocol strings differ (string comparison).

Common situations: Adding both an http and an http2 endpoint pointing at the same container port; multiple resources sharing a port with different transport settings from WithEndpoint(transport: ...).

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/6cceee01cb6ba495. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:1525

            }

            var protocol = ResolveSandboxPortProtocol(resource.TargetResource, resolvedEndpoint.Endpoint);
            AzureSandboxEndpointOptions? resolvedEndpointOptions = null;
            endpointOptions?.TryGetValue(resolvedEndpoint.Endpoint.Name, out resolvedEndpointOptions);
            unmatchedEndpointOptions?.Remove(resolvedEndpoint.Endpoint.Name);
            var endpoint = new SandboxEndpoint(
                resolvedEndpoint.Endpoint.Name,
                resolvedTargetPort,
                IsExternal: true,
                IsHttp: true,
                protocol,
                resolvedEndpointOptions?.Anonymous);

            if (endpoints.TryGetValue(resolvedTargetPort, out var existingEndpoint))
            {
                if (!string.Equals(existingEndpoint.Protocol, endpoint.Protocol, StringComparison.Ordinal))
                {
                    throw new NotSupportedException($"Endpoint '{resolvedEndpoint.Endpoint.Name}' on resource '{resource.TargetResource.Name}' shares target port {resolvedTargetPort} with endpoint '{existingEndpoint.Name}' but uses a different transport. Azure sandbox ports support a single HTTP protocol per target port.");
                }

                if (existingEndpoint.Anonymous is not null &&
                    endpoint.Anonymous is not null &&
                    existingEndpoint.Anonymous != endpoint.Anonymous)
                {
                    throw new NotSupportedException($"Endpoint '{resolvedEndpoint.Endpoint.Name}' on resource '{resource.TargetResource.Name}' shares target port {resolvedTargetPort} with endpoint '{existingEndpoint.Name}' but configures a different anonymous-access policy. Azure sandbox ports support a single access policy per target port.");
                }

                endpoints[resolvedTargetPort] = existingEndpoint with
                {
                    IsExternal = existingEndpoint.IsExternal || endpoint.IsExternal,
                    IsHttp = existingEndpoint.IsHttp || endpoint.IsHttp,
                    Anonymous = existingEndpoint.Anonymous ?? endpoint.Anonymous
                };
            }
            else
            {

View on GitHub (pinned to 25830f84bd)