{"record":{"id":"0a4e8270d119d8ff","repo":"microsoft/aspire","slug":"host-endpoint-endpoint-name-on-resource-re-resource-name","errorCode":null,"errorMessage":"Host endpoint '{endpoint.Name}' on resource '{re.Resource.Name}' should have an associated DCP Service resource already set up","messagePattern":"Host endpoint '(.+?)' on resource '(.+?)' should have an associated DCP Service resource already set up","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/ContainerCreator.cs","lineNumber":447,"sourceCode":"            }\n\n            if (useTunnel && endpoint.Protocol != ProtocolType.Tcp)\n            {\n                resourceLogger.LogWarning(\"Host endpoint '{EndpointName}' on resource '{HostResource}' is referenced by a container resource, but the endpoint is using a network protocol '{Protocol}' other than TCP. Only TCP is supported for container-to-host references.\", endpoint.Name, re.Resource.Name, endpoint.Protocol);\n                continue;\n            }\n\n            var svc = Service.Create(serviceName);\n            svc.Spec.AddressAllocationMode = AddressAllocationModes.Proxyless;\n            svc.Spec.Protocol = PortProtocol.FromProtocolType(endpoint.Protocol);\n\n            var serverSvc = _appResources.Get().OfType<ServiceWithModelResource>().FirstOrDefault(swr =>\n                StringComparers.ResourceName.Equals(swr.ModelResource.Name, re.Resource.Name) &&\n                StringComparers.EndpointAnnotationName.Equals(swr.EndpointAnnotation.Name, endpoint.Name)\n            );\n            if (serverSvc is null)\n            {\n                throw new InvalidDataException($\"Host endpoint '{endpoint.Name}' on resource '{re.Resource.Name}' should have an associated DCP Service resource already set up\");\n            }\n\n            TunnelConfiguration? tunnelConfig = null;\n            if (useTunnel)\n            {\n                tunnelConfig = new TunnelConfiguration\n                {\n                    Name = serviceName,\n                    ServerServiceName = serverSvc.DcpResource.Metadata.Name,\n                    ServerServiceNamespace = string.Empty,\n                    ClientServiceName = svc.Metadata.Name,\n                    ClientServiceNamespace = string.Empty\n                };\n            }\n\n            svc.Annotate(CustomResource.ResourceNameAnnotation, re.Resource.Name);\n            svc.Annotate(CustomResource.EndpointNameAnnotation, endpoint.Name);\n            svc.Annotate(CustomResource.ContainerNetworkAnnotation, KnownNetworkIdentifiers.DefaultAspireContainerNetwork.Value);","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/ContainerCreator.cs#L429-L465","documentation":"Before wiring host-resource endpoints into container networks, Aspire expects a matching DCP Service resource (per resource name + endpoint name) to have been created earlier. When none is found, an InvalidDataException is thrown - the endpoint/Service pre-setup step was skipped or ran out of order.","triggerScenarios":"CreateContainerNetworkServicesForHostResource processes a HostResourceWithEndpoints whose endpoint name has no ServiceWithModelResource with the same model resource name and endpoint annotation name in _appResources.","commonSituations":"Custom pipelines or eventing that create host resources without running the Service setup step, endpoint renamed/added after services were generated, or interacting with container-network features out of order in custom code.","solutions":["Ensure the DCP Service creation step runs before container network setup for the resource","Verify endpoint names match exactly (case-sensitive) between the resource and its Service","Recreate/refresh the app model so Services are regenerated for all endpoints"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var svc = appResources.OfType<ServiceWithModelResource>().FirstOrDefault(s => StringComparers.ResourceName.Equals(s.ModelResource.Name, name) && StringComparers.EndpointAnnotationName.Equals(s.EndpointAnnotation.Name, endpointName)); if (svc is null) { /* run service setup first */ }","typeGuard":null,"tryCatchPattern":"try { await networkSetup(re); } catch (InvalidDataException ex) when (ex.Message.Contains(\"DCP Service resource\")) { logger.LogError(ex, \"Service for endpoint {Endpoint} missing; run service generation first\", endpointName); }","preventionTips":["Run the DCP Service creation step before container network wiring","Keep endpoint names stable after initial model build","In custom pipelines, follow the built-in prepare-then-create ordering"],"tags":["containers","networking","endpoints"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}