{"record":{"id":"91269c9cf0c8fd93","repo":"microsoft/aspire","slug":"azure-sandbox-resource-resource-targetresource-name-in","errorCode":null,"errorMessage":"Azure sandbox resource '{resource.TargetResource.Name}' in sandbox group '{resource.Parent.Name}' references resource '{dependency.Name}' in sandbox group '{producer.Parent.Name}', but cross-group sandbox references are not supported. Deploy both resources to the same sandbox group.","messagePattern":"Azure sandbox resource '(.+?)' in sandbox group '(.+?)' references resource '(.+?)' in sandbox group '(.+?)', but cross-group sandbox references are not supported\\. Deploy both resources to the same sandbox group\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs","lineNumber":169,"sourceCode":"        if (resource.Parent.ContainerRegistry is { } registry)\n        {\n            deploySteps.DependsOn(context.GetSteps(registry, \"acr-login\"));\n        }\n\n        var executionContext = context.Services.GetRequiredService<DistributedApplicationExecutionContext>();\n        var dependencies = await resource.TargetResource.GetResourceDependenciesAsync(\n            executionContext,\n            ResourceDependencyDiscoveryMode.DirectOnly).ConfigureAwait(false);\n        foreach (var dependency in dependencies)\n        {\n            if (dependency.GetDeploymentTargetAnnotation()?.DeploymentTarget is not AzureSandboxContainerResource producer)\n            {\n                continue;\n            }\n\n            if (!ReferenceEquals(producer.Parent, resource.Parent))\n            {\n                throw new NotSupportedException(\n                    $\"Azure sandbox resource '{resource.TargetResource.Name}' in sandbox group '{resource.Parent.Name}' references resource '{dependency.Name}' in sandbox group '{producer.Parent.Name}', but cross-group sandbox references are not supported. Deploy both resources to the same sandbox group.\");\n            }\n\n            var producerSteps = context.GetSteps(producer, WellKnownPipelineTags.DeployCompute);\n            foreach (var consumerStep in deploySteps)\n            {\n                foreach (var producerStep in producerSteps)\n                {\n                    if (WouldCreateDependencyCycle(context.Steps, consumerStep, producerStep))\n                    {\n                        throw new InvalidOperationException(\n                            $\"Azure sandbox resources '{resource.TargetResource.Name}' and '{producer.TargetResource.Name}' have a circular deployment dependency.\");\n                    }\n\n                    consumerStep.DependsOn(producerStep);\n                }\n            }\n        }","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs#L151-L187","documentation":"During sandbox deployment pipeline configuration, Aspire orders consumer steps to depend on producer steps that supply referenced values. If a sandbox resource references a value produced by a resource in a different sandbox group, the deploy ordering cannot be expressed within one group, so NotSupportedException is thrown. Cross-sandbox-group references are simply not supported.","triggerScenarios":"Deploying Azure sandbox resources where resource A in sandbox group G1 references an output/endpoint of resource B in sandbox group G2, so ConfigureDeployOrderingAsync detects producer.Parent != resource.Parent.","commonSituations":"Splitting an app's sandboxes across multiple sandbox groups (e.g. per-team or per-environment groups) while still wiring a container in one group to a database or service in another group.","solutions":["Move the referencing resource and its dependency into the same sandbox group (set the same parent).","If the resources must live in separate groups, break the direct reference and pass the value explicitly via configuration/connection strings rather than resource references.","Consolidate the sandbox groups so all interdependent resources share one group."],"exampleFix":"// before\nvar db = builder.AddAzureSandboxPostgres(\"db\", sandboxGroupA);\nvar api = builder.AddAzureSandboxContainer(\"api\", sandboxGroupB).WithReference(db);\n// after\nvar api = builder.AddAzureSandboxContainer(\"api\", sandboxGroupA).WithReference(db);","handlingStrategy":"validation","validationCode":"// before deploy: assert every referenced producer is in the same sandbox group\nforeach (var r in resources)\n    foreach (var dep in r.References)\n        if (!ReferenceEquals(dep.Parent, r.Parent))\n            throw new InvalidOperationException($\"{r.Name} references cross-group {dep.Name}\");","typeGuard":null,"tryCatchPattern":"try { await deployment.ConfigureDeployOrderingAsync(...); }\ncatch (NotSupportedException ex) { /* regroup resources into one sandbox group or pass values via config */ throw new InvalidOperationException(ex.Message, ex); }","preventionTips":["Model each mutually communicating set of resources inside one sandbox group.","Avoid WithReference across groups; pass endpoints via explicit configuration instead.","Review sandbox group assignments during planning, before deployment."],"tags":["azure","sandboxes","deployment"],"backgroundTag":"unsupported-operation","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"}