{"record":{"id":"354446495a0ba0fe","repo":"microsoft/aspire","slug":"endpoint-endpointname-on-resource-resource-targetresource","errorCode":null,"errorMessage":"Endpoint '{endpointName}' on resource '{resource.TargetResource.Name}' is not exposed by the Azure sandbox deployment target. Configure it as an external HTTP endpoint before referencing its sandbox URL.","messagePattern":"Endpoint '(.+?)' on resource '(.+?)' is not exposed by the Azure sandbox deployment target\\. Configure it as an external HTTP endpoint before referencing its sandbox URL\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs","lineNumber":184,"sourceCode":"        {\n            if (resolvedTargetPort is int targetPort &&\n                endpoint.TargetPort == targetPort)\n            {\n                fallbackEndpoint ??= endpoint;\n            }\n\n            if (string.Equals(endpoint.Name, endpointName, StringComparison.Ordinal))\n            {\n                return endpoint;\n            }\n        }\n\n        if (fallbackEndpoint is { } matchedEndpoint)\n        {\n            return matchedEndpoint;\n        }\n\n        throw new InvalidOperationException($\"Endpoint '{endpointName}' on resource '{resource.TargetResource.Name}' is not exposed by the Azure sandbox deployment target. Configure it as an external HTTP endpoint before referencing its sandbox URL.\");\n    }\n\n    private static int? ResolveEndpointTargetPort(AzureSandboxContainerResource resource, string endpointName)\n    {\n        foreach (var resolvedEndpoint in resource.TargetResource.ResolveEndpoints())\n        {\n            if (string.Equals(resolvedEndpoint.Endpoint.Name, endpointName, StringComparison.Ordinal))\n            {\n                return AzureSandboxContainerDeployment.ResolveSandboxTargetPort(resource.TargetResource, resolvedEndpoint);\n            }\n        }\n\n        return null;\n    }\n}\n","sourceCodeStart":166,"sourceCodeEnd":200,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs#L166-L200","documentation":"Thrown by ResolveSandboxEndpoint when no endpoint on the sandbox container resource matches the requested name (or falls back to target-port matching) among the endpoints exposed by the Azure sandbox deployment target. The caller is told to mark the endpoint as an external HTTP endpoint so the sandbox will expose and persist a URL for it.","triggerScenarios":"Resolving a sandbox endpoint for endpointName where resource.TargetResource.ResolveEndpoints() contains no external HTTP endpoint with that name (and no endpoint sharing the target port as a fallback).","commonSituations":"Endpoint declared without isExternal/external HTTP semantics; misspelled endpoint name; the endpoint was added to the resource after the sandbox deployment state was generated.","solutions":["Mark the endpoint as an external HTTP endpoint (e.g. .WithHttpEndpoint(..., isExternal: true)) before referencing its sandbox URL.","Double-check the endpoint name string matches the declaration exactly (case-sensitive).","Redeploy the sandbox so the newly exposed endpoint is persisted in the deployment state Ports section.","Confirm the consuming reference targets the same resource the endpoint was declared on."],"exampleFix":"// before\n.WithHttpEndpoint(targetPort: 8080, name: \"http\")\n// after\n.WithHttpEndpoint(targetPort: 8080, name: \"http\", isExternal: true);","handlingStrategy":"validation","validationCode":"bool EndpointExists(IResource r, string name) =>\n    r.ResolveEndpoints().Any(e => string.Equals(e.EndpointName, name, StringComparison.Ordinal));","typeGuard":null,"tryCatchPattern":"try { var url = await provider.GetValueAsync(); }\ncatch (InvalidOperationException ex) { logger.LogError(ex, \"Unknown or unexposed endpoint '{Name}'\", name); throw; }","preventionTips":["Use constants for endpoint names to avoid typos.","Configure endpoints with isExternal: true before consumers reference their URLs.","Re-run deployment whenever endpoint declarations change."],"tags":["azure","sandbox","endpoint","configuration"],"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-21T04:17:39.646Z"}