{"record":{"id":"5a68ddae90e256e0","repo":"microsoft/aspire","slug":"the-container-registry-configured-for-the-azure-container","errorCode":null,"errorMessage":"The container registry configured for the Azure Container App Environment '{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 Container App Environment '(.+?)' 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.AppContainers/AzureContainerAppEnvironmentResource.cs","lineNumber":331,"sourceCode":"    }\n\n    /// <summary>\n    /// Gets the Azure Container Registry resource used by this Azure Container App Environment resource.\n    /// </summary>\n    public AzureContainerRegistryResource? ContainerRegistry\n    {\n        get\n        {\n            var registry = GetContainerRegistry();\n\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 Container App Environment '{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\n            return azureRegistry;\n        }\n    }\n\n#pragma warning disable CS0618 // Type or member is obsolete\n    ReferenceExpression IAzureContainerRegistry.ManagedIdentityId => ReferenceExpression.Create($\"{ContainerRegistryManagedIdentityId}\");\n#pragma warning restore CS0618 // Type or member is obsolete\n\n    /// <inheritdoc/>\n    [Experimental(\"ASPIRECOMPUTE002\", UrlFormat = \"https://aka.ms/aspire/diagnostics/{0}\")]\n    public ReferenceExpression GetHostAddressExpression(EndpointReference endpointReference)\n    {\n        var resource = endpointReference.Resource;","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs#L313-L349","documentation":"An Azure Container App Environment requires its configured container registry to be an Aspire AzureContainerRegistryResource. When the environment's registry is some other container registry resource type, this InvalidOperationException is thrown, directing you to configure it via .WithAzureContainerRegistry().","triggerScenarios":"Publishing a model where the Azure Container App Environment has a registry annotation pointing at a non-Azure registry resource (e.g. a generic/ACR-modelled registry from another integration or a custom IContainerRegistry implementation), during Bicep generation of the environment module.","commonSituations":"Mixing registry integrations, replacing the default Azure Container Registry with a custom registry resource, or upgrading models where an environment was configured with an incompatible registry type.","solutions":["Call .WithAzureContainerRegistry() on the environment to configure a supported AzureContainerRegistryResource","Remove any custom/foreign registry resource attached to the Container App Environment","If you must use a non-Azure registry, do not attach it via the Container App Environment registry configuration"],"exampleFix":"// before\nvar env = builder.AddAzureContainerAppEnvironment(\"env\");\nenv.WithCustomRegistry(nonAzureRegistry);\n// after\nvar env = builder.AddAzureContainerAppEnvironment(\"env\");\nenv.WithAzureContainerRegistry();","handlingStrategy":"type-guard","validationCode":"if (registry is not AzureContainerRegistryResource)\n{\n    throw new InvalidOperationException(\"Call WithAzureContainerRegistry() to use a supported registry\");\n}","typeGuard":"static bool IsAzureRegistry(IResource registry) => registry is AzureContainerRegistryResource;","tryCatchPattern":"try { await PublishAsync(model); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Azure Container Registry\"))\n{\n    logger.LogError(ex, \"Environment registry is not an AzureContainerRegistryResource\");\n}","preventionTips":["Always configure environment registries via .WithAzureContainerRegistry()","Do not attach foreign/custom registry resources to Container App Environments","Validate the registry resource type before publishing"],"tags":["azure","container-apps","container-registry","publish"],"backgroundTag":"type-mismatch","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"}