{"record":{"id":"50c85e7df1ab4314","repo":"microsoft/aspire","slug":"resource-resource-name-does-not-have-a-compute-environment","errorCode":null,"errorMessage":"Resource '{resource.Name}' does not have a compute environment. Ensure a compute environment (e.g., Azure Container Apps, Azure App Service) is configured in the application model.","messagePattern":"Resource '(.+?)' does not have a compute environment\\. Ensure a compute environment \\(e\\.g\\., Azure Container Apps, Azure App Service\\) is configured in the application model\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs","lineNumber":214,"sourceCode":"            .OfType<AzureFrontDoorOriginAnnotation>()\n            .Any(a => a.Resource.Name == resource.Resource.Name))\n        {\n            throw new InvalidOperationException(\n                $\"Origin resource '{resource.Resource.Name}' has already been added to Azure Front Door resource '{builder.Resource.Name}'. \" +\n                \"Each origin can only be added once.\");\n        }\n\n        return builder.WithAnnotation(new AzureFrontDoorOriginAnnotation(resource.Resource));\n    }\n\n    private static IComputeEnvironmentResource GetEffectiveComputeEnvironment(IResource resource)\n    {\n        if (ComputeEnvironmentEndpointResolver.TryGetEffectiveComputeEnvironment(resource, out var computeEnvironment))\n        {\n            return computeEnvironment;\n        }\n\n        throw new InvalidOperationException(\n            $\"Resource '{resource.Name}' does not have a compute environment. \" +\n            \"Ensure a compute environment (e.g., Azure Container Apps, Azure App Service) is configured in the application model.\");\n    }\n\n    private static EndpointReference GetOriginEndpoint(IResourceWithEndpoints resource)\n    {\n        var externalHttpEndpoint = resource.GetEndpoints()\n            .Where(e => e.EndpointAnnotation.UriScheme is \"http\" or \"https\")\n            .FirstOrDefault(e => e.EndpointAnnotation.IsExternal);\n\n        if (externalHttpEndpoint is not null)\n        {\n            return externalHttpEndpoint;\n        }\n\n        throw new InvalidOperationException(\n            $\"Resource '{resource.Name}' does not have an external HTTP or HTTPS endpoint. \" +\n            \"Azure Front Door requires an origin to expose an external HTTP or HTTPS endpoint. \" +","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs#L196-L232","documentation":"Aspire's Azure Front Door integration requires every origin resource to belong to a compute environment (such as Azure Container Apps or Azure App Service), which is discovered via ComputeEnvironmentEndpointResolver. When GetEffectiveComputeEnvironment cannot find one on the resource (or its parents), it throws this InvalidOperationException during model finalization. The library needs the environment to place the origin correctly in the published Front Door topology.","triggerScenarios":"Calling AddFrontDoor/addFrontDoor origin APIs with a resource (e.g., a project or container) that never had a compute environment attached, e.g. a plain container or executable resource without WithComputeEnvironment/Azure hosting environment wiring.","commonSituations":"Adding a backend project to Front Door in an app that only configures containers without a Container App environment; migrating an AppHost from plain run-mode resources to publish mode; forgetting to add the ACA/Azure App Service hosting extension that attaches the environment annotation.","solutions":["Ensure the origin resource is hosted in a compute environment, e.g. add builder.AddContainerAppEnvironment(...) (Azure Container Apps) or an Azure App Service environment to the AppHost before publishing.","Verify the resource passed as a Front Door origin is a project/container wired to that environment, not a bare resource.","Check that the Azure provisioning packages (Aspire.Hosting.Azure.AppContainers / Azure.AppService) are referenced so environment annotations are created."],"exampleFix":"// before\nvar frontDoor = builder.AddAzureFrontDoor(\"fd\");\nfrontDoor.AddOrigin(builder.AddContainer(\"api\", \"image\")); // no compute environment\n\n// after\nbuilder.AddContainerAppEnvironment(\"env\");\nvar api = builder.AddContainer(\"api\", \"image\"); // participates in the ACA environment\nvar frontDoor = builder.AddAzureFrontDoor(\"fd\");\nfrontDoor.AddOrigin(api);","handlingStrategy":"validation","validationCode":"var hasEnv = resource.Annotations.OfType<Microsoft.Extensions.Logging.ILoggerAnnotation>().Any() || ComputeEnvironmentEndpointResolver.TryGetEffectiveComputeEnvironment(resource, out _); // check before AddOrigin; simpler: only add resources created via AddProject/AddContainer in an AppHost that called AddContainerAppEnvironment\n","typeGuard":"static bool HasComputeEnvironment(IResource resource) => ComputeEnvironmentEndpointResolver.TryGetEffectiveComputeEnvironment(resource, out _);","tryCatchPattern":"try { frontDoor.AddOrigin(resource); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"compute environment\")) { /* configure ACA environment and retry model construction */ }","preventionTips":["Always add a compute environment (AddContainerAppEnvironment / App Service env) to AppHosts used for Azure publish.","Only use project/container resources as Front Door origins.","Keep Azure hosting integration packages referenced so environment annotations exist."],"tags":["aspire","azure-frontdoor","compute-environment","publish-time"],"backgroundTag":"missing-required-config","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"}