Skip to content

Conversation

@eerhardt
Copy link
Member

@eerhardt eerhardt commented Jan 7, 2026

Description

There are many cases where we need to order BeforeStartEvent subscriptions. For example, if someone wants something to run before the AzureResourcePreparer, so it can add role assignments correctly, there is no way to ensure the AzureResourcePreparer's BeforeStartEvent subscription has already run.

To fix this, we reuse the Pipeline steps, which already has dependencies built in to it. Then we convert the Azure BeforeStartEvent subscriptions to pipeline steps, so they can be depended on (or required by).

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13780

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13780"

@eerhardt eerhardt requested a review from davidfowl January 7, 2026 00:26
// for elements.
return builder.AddResource(resource)
.ExcludeFromManifest();
.ExcludeFromManifest()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be helpful to note that we need to do this because the AzureEnvironmentResource needs to show up in the app model during run mode so that we can discover the pipeline step annotations on it but it needs to be hidden from the end-user.

If we continue down this route of making events into pipeline steps, we might need a better way to define a resource that is discoverable in the app model but not visible to the end user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add another comment here, and I opened Add an API for marking a resource as hidden in the dashboard (dotnet/aspire#13799) for this.

{
var azureResources = AzureResourcePreparer.GetAzureResourcesFromAppModel(@event.Model);
// Only run in RunMode
if (!executionContext.IsRunMode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think eventually we'll get to a point where we don't run this in RunMode either and the provisioning at run-mode also happens via the provision infrastructure meta-step.

Maybe we work towards that in a follow-up PR...?

Copy link
Member Author

@eerhardt eerhardt Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I had a similar thought when I was trying to name the steps. 😄 We already have a provisionStep named provision-azure-bicep-resources. And when I added a new step for the run-mode provision, it was conflicting, which made me think that we could think about merging these now.

Maybe we work towards that in a follow-up PR...?

For sure not as part of this PR.

builder.Services.TryAddSingleton<AzureResourcePreparer>();
builder.Services.TryAddSingleton<AzureProvisioner>();

//#pragma warning disable ASPIREPIPELINES001 // Pipeline APIs are experimental
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem did you run into with this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - this is old and needs to be deleted.

The problem I hit in the commented out code is that AddAzureProvisioning gets called multiple times (from each Azure resource). At first I was just adding the step, but that fails for duplicate steps. That caused me to look at a TryAddStep API on the pipeline, but I changed it to add the steps from the resource, which is already only added once, so the steps only get added once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants