{"record":{"id":"64c047858d6444c0","repo":"microsoft/aspire","slug":"endpoint-endpointreferenceexpression-endpoint-endpointname-64c047","errorCode":null,"errorMessage":"Endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' on resource '{_resource.TargetResource.Name}' is not exposed by the Azure sandbox deployment target.","messagePattern":"Endpoint '(.+?)' on resource '(.+?)' is not exposed by the Azure sandbox deployment target\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs","lineNumber":124,"sourceCode":"            EndpointProperty.Url => url,\n            EndpointProperty.Host or EndpointProperty.IPV4Host => uri.Host,\n            EndpointProperty.Port => uri.Port.ToString(CultureInfo.InvariantCulture),\n            EndpointProperty.TargetPort => _targetPort.ToString(CultureInfo.InvariantCulture),\n            EndpointProperty.Scheme => uri.Scheme,\n            EndpointProperty.HostAndPort => uri.IsDefaultPort ? uri.Host : uri.Authority,\n            EndpointProperty.TlsEnabled => string.Equals(uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) ? bool.TrueString : bool.FalseString,\n            _ => throw new InvalidOperationException($\"The property '{_endpointReferenceExpression.Property}' is not supported for the endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}'.\")\n        };\n    }\n\n    private InvalidOperationException CreateUnresolvedEndpointException() =>\n        new($\"Azure sandbox endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' on resource '{_resource.TargetResource.Name}' does not have a deployed URL yet. Runtime sandbox URLs cannot be used as first-pass Azure provisioning values; deploy the producing sandbox before resolving this reference.\");\n\n    private bool TryGetUrl(DeploymentStateSection stateSection, [NotNullWhen(true)] out string? url)\n    {\n        url = null;\n        var sandboxEndpoint = _sandboxEndpoint ??\n            throw new InvalidOperationException($\"Endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' on resource '{_resource.TargetResource.Name}' is not exposed by the Azure sandbox deployment target.\");\n\n        // Sandbox deployment state stores exposed ADC ports as:\n        //   { \"Ports\": [{ \"Name\": \"http\", \"Port\": 8080, \"Url\": \"https://<sandbox-id>--8080.<region>.adcproxy.io/\" }] }\n        // Multiple Aspire endpoints can share the same target port, so fall back to target-port\n        // matching when the persisted representative name differs from the requested endpoint name.\n        if (stateSection.Data[\"Ports\"] is not JsonArray ports)\n        {\n            return false;\n        }\n\n        JsonObject? fallbackPort = null;\n        foreach (var port in ports.OfType<JsonObject>())\n        {\n            if (port[\"Port\"]?.GetValue<int>() == sandboxEndpoint.TargetPort)\n            {\n                fallbackPort ??= port;\n            }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs#L106-L142","documentation":"Thrown by TryGetUrl when the provider's _sandboxEndpoint is null, i.e. the endpoint being referenced was never exposed/resolved by the Azure sandbox deployment target. Without a resolved sandbox endpoint there is no corresponding deployment-state URL to look up.","triggerScenarios":"GetValueAsync → TryGetUrl on a property provider whose endpoint was not registered as an external HTTP endpoint on the sandbox deployment target, so ResolveSandboxEndpoint produced nothing and _sandboxEndpoint stayed null.","commonSituations":"Referencing an endpoint's URL from a consuming resource while the producing container's endpoint is not marked external/HTTP in the sandbox target; endpoint renamed on the producer but not the consumer.","solutions":["Configure the producing endpoint as an external HTTP endpoint on the Azure sandbox container (WithHttpEndpoint + external exposure).","Ensure endpoint names match exactly between the producer's declaration and the consumer's EndpointReference.","Re-run the deployment so the deployment state contains the Ports entry for this endpoint.","Verify the resource is actually an AzureSandboxContainerResource whose target exposes the endpoint."],"exampleFix":"// before\n.WithEndpoint(name: \"http\") // not external/HTTP for sandbox\n// after\n.WithHttpEndpoint(port: 8080, targetPort: 8080, name: \"http\", isExternal: true);","handlingStrategy":"validation","validationCode":"bool IsExposedExternalHttp(IResource r, string endpointName) =>\n    r.ResolveEndpoints().Any(e => e.EndpointName == endpointName && e.IsExternal && string.Equals(e.UriScheme, \"http\", StringComparison.OrdinalIgnoreCase));","typeGuard":null,"tryCatchPattern":"try { var url = await provider.GetValueAsync(); }\ncatch (InvalidOperationException ex) { logger.LogError(ex, \"Endpoint not exposed by sandbox target\"); throw; }","preventionTips":["Mark every endpoint referenced across resources as an external HTTP endpoint for sandbox deployments.","Keep endpoint names synchronized between producer and consumer.","Redeploy after adding new endpoints so state is refreshed."],"tags":["azure","sandbox","endpoint","state"],"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"}