{"record":{"id":"407d9cd05d9a0fc4","repo":"microsoft/aspire","slug":"the-container-registry-configured-for-the-azure-sandbox","errorCode":null,"errorMessage":"The container registry configured for the Azure sandbox group '{Name}' is not an Azure Container Registry. Only Azure Container Registry resources are supported. Use '.WithAzureContainerRegistry()' to configure an Azure Container Registry.","messagePattern":"The container registry configured for the Azure sandbox group '(.+?)' is not an Azure Container Registry\\. Only Azure Container Registry resources are supported\\. Use '\\.WithAzureContainerRegistry\\(\\)' to configure an Azure Container Registry\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxGroupResource.cs","lineNumber":152,"sourceCode":"\n    IAzureContainerRegistryResource? IAzureComputeEnvironmentResource.ContainerRegistry => ContainerRegistry;\n\n    /// <summary>\n    /// Gets the Azure Container Registry resource used by this sandbox group.\n    /// </summary>\n    public AzureContainerRegistryResource? ContainerRegistry\n    {\n        get\n        {\n            var registry = GetContainerRegistry();\n            if (registry is null)\n            {\n                return null;\n            }\n\n            if (registry is not AzureContainerRegistryResource azureRegistry)\n            {\n                throw new InvalidOperationException(\n                    $\"The container registry configured for the Azure sandbox group '{Name}' is not an Azure Container Registry. \" +\n                    $\"Only Azure Container Registry resources are supported. Use '.WithAzureContainerRegistry()' to configure an Azure Container Registry.\");\n            }\n\n            return azureRegistry;\n        }\n    }\n\n    internal static string GetDashboardUrl(string subscriptionId, string resourceGroupName, string sandboxGroupName)\n    {\n        return $\"{DashboardBaseUrl}/sandbox-groups/{Uri.EscapeDataString(subscriptionId)}/{Uri.EscapeDataString(resourceGroupName)}/{Uri.EscapeDataString(sandboxGroupName)}\";\n    }\n\n    private async Task AddDashboardToPipelineSummaryAsync(PipelineStepContext context)\n    {\n        if (this.IsExcludedFromPublish())\n        {\n            return;","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxGroupResource.cs#L134-L170","documentation":"Thrown when constructing or initializing an AzureSandboxGroupResource whose configured container registry is present but is not an AzureContainerRegistryResource. Only Azure Container Registry is supported for sandbox image deployment; any other registry resource type is rejected with guidance to use .WithAzureContainerRegistry().","triggerScenarios":"Adding a generic container registry resource (e.g. a plain ContainerRegistryResource or third-party registry resource) to an AzureSandboxGroupResource; the check `registry is not AzureContainerRegistryResource azureRegistry` fails and throws.","commonSituations":"Using .WithContainerRegistry() or a Docker Hub / generic registry extension instead of .WithAzureContainerRegistry(); upgrading from an older pattern that configured a raw registry resource; copy-pasting registry wiring from a non-sandbox sample.","solutions":["Replace the registry configuration with .WithAzureContainerRegistry() on the Azure sandbox group resource.","Remove the non-Azure registry resource from the sandbox group configuration.","Provision an Azure Container Registry resource and attach it via the sandbox-specific API.","Check for extension methods like WithContainerRegistry in your AppHost and switch them to the sandbox-supported equivalent."],"exampleFix":"// before\nsandboxGroup.WithContainerRegistry(registryResource);\n// after\nsandboxGroup.WithAzureContainerRegistry();","handlingStrategy":"validation","validationCode":"bool IsAzureContainerRegistry(IResource? registry) => registry is AzureContainerRegistryResource;","typeGuard":"bool IsAcr(IResource? r) => r is AzureContainerRegistryResource;","tryCatchPattern":"try { builder.AddAzureSandboxGroup(\"sandbox\"); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Azure Container Registry\")) { /* reconfigure registry and retry */ }","preventionTips":["Always use .WithAzureContainerRegistry() for sandbox groups.","Do not attach generic or third-party registry resources to sandbox groups.","Review AppHost registry wiring when migrating from non-sandbox samples."],"tags":["azure","sandbox","container-registry","configuration"],"backgroundTag":"invalid-argument-value","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"}