BeforeStartEvent is too early in the pipeline for ACA / AppService resources to process compute resources
The ACA AzureContainerAppsInfrastructure hooks to BeforeStartEvent to process all the compute resources in the model.
https://github.com/dotnet/aspire/blob/b3582d25c4e134bc6c506ef178b92829eca51ba9/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppsInfrastructure.cs#L23-L79
This event is too early in the pipeline because it doesn't give anyone else a chance to run logic before BeforeStartEvent.
For example, I want to add environment variables to a ProjectResource in an event subscription. However, since AzureContainerAppsInfrastructure hooks to BeforeStartEvent, which is the very first event that runs in the pipeline, there is no way to hook an event to add the environment variable.
cc @captainsafia @davidfowl @mitchdenny
We need to run these from a different event so that BeforeStartEvent can be used for this mutation.
@ShilpiRach ran into a similar issue when adding support for expected host name look ups to Azure App Service.
We're exploring modeling the logic currently in BeforeStart as a pipeline step so we can wire up dependencies for these things.
If that works, we'll probably want to apply the same behavior to the ACA environment.
The ACA logic should be implemented using a parameter plus a step in the pipeline https://github.com/dotnet/aspire/issues/12984.
Not saying we shouldn't fix this but, I don't think we should implement the dns logic this way.
@davidfowl , @captainsafia - https://github.com/dotnet/aspire/issues/12984 (or fixing the issue by moving AppService resource creation to a later point) would also help with slot support.
For both DNL hostname / main app existence check, we need provisioning context to be available to make the required ARM calls.