Edit

Share via


Activity reporter and pipeline context renamed

In Aspire 13.0, the publishing activity reporter APIs and context types have been renamed to better reflect the pipeline architecture. The publishing step creation process has been simplified, with steps now automatically created during pipeline execution rather than requiring explicit creation within step actions.

Version introduced

Aspire 13.0 Preview 1

Previous behavior

The previous API used publishing-specific names and required explicit step creation within pipeline actions:

builder.Pipeline.AddStep("assign-storage-role", async (context) =>
{
    var roleAssignmentStep = await context.ActivityReporter
        .CreateStepAsync($"assign-storage-role", context.CancellationToken);
    
    await using (roleAssignmentStep.ConfigureAwait(false))
    {
        var assignRoleTask = await roleAssignmentStep
            .CreateTaskAsync($"Granting file share access...", context.CancellationToken);
        
        await using (assignRoleTask.ConfigureAwait(false))
        {
            // ... task work
        }
    }
});

The types used were:

  • DeployingContext - Provided context for pipeline execution
  • IPublishingActivityReporter - Interface for reporting activities
  • PublishingActivityReporter - Implementation of the activity reporter
  • NullPublishingActivityReporter - Null object pattern implementation
  • IPublishingStep - Interface for publishing steps
  • IPublishingTask - Interface for publishing tasks

New behavior

The API now uses pipeline-specific names and automatically creates steps during pipeline execution:

builder.Pipeline.AddStep("assign-storage-role", async (stepContext) =>
{
    var assignRoleTask = await stepContext.ReportingStep
        .CreateTaskAsync($"Granting file share access...", stepContext.CancellationToken);
    
    await using (assignRoleTask.ConfigureAwait(false))
    {
        // ... task work
    }
});

The types have been renamed as follows:

  • DeployingContextPipelineContext - Shared context across all pipeline steps
  • IPublishingActivityReporterIPipelineActivityReporter - Interface for reporting pipeline activities
  • PublishingActivityReporterPipelineActivityReporter - Implementation of the pipeline activity reporter
  • NullPublishingActivityReporterNullPipelineActivityReporter - Null object pattern implementation
  • IPublishingStepIReportingStep - Interface for reporting steps
  • IPublishingTaskIReportingTask - Interface for reporting tasks

Additionally, a new PipelineStepContext type has been introduced that combines the shared PipelineContext with a step-specific IReportingStep, allowing each step to track its own tasks and completion state independently.

Type of breaking change

This change can affect binary compatibility and source compatibility.

Reason for change

The previous three-level hierarchy (ActivityReporter → Step → Task) was unnecessarily complex. The new architecture simplifies this by automatically creating steps during pipeline execution and integrating step management directly into the pipeline. This provides a cleaner separation between the shared pipeline context and step-specific execution context, making the API more intuitive and reducing boilerplate code.

Update your code to use the new type names and simplified step creation pattern:

  1. Replace DeployingContext with PipelineContext for shared pipeline context or PipelineStepContext for step-specific context.
  2. Replace IPublishingActivityReporter with IPipelineActivityReporter.
  3. Replace PublishingActivityReporter with PipelineActivityReporter.
  4. Replace NullPublishingActivityReporter with NullPipelineActivityReporter.
  5. Replace IPublishingStep with IReportingStep.
  6. Replace IPublishingTask with IReportingTask.
  7. Update pipeline step actions to accept PipelineStepContext instead of DeployingContext.
  8. Remove explicit step creation calls within pipeline actions and use the automatically created context.ReportingStep instead.

Migration example:

// Before
builder.Pipeline.AddStep("my-step", async (context) =>
{
    var step = await context.ActivityReporter
        .CreateStepAsync("my-step", context.CancellationToken);
    
    await using (step.ConfigureAwait(false))
    {
        var task = await step.CreateTaskAsync("Doing work...", context.CancellationToken);
        await using (task.ConfigureAwait(false))
        {
            // Do work
            await task.CompleteAsync("Done", CompletionState.Completed, context.CancellationToken);
        }
    }
});

// After
builder.Pipeline.AddStep("my-step", async (stepContext) =>
{
    var task = await stepContext.ReportingStep
        .CreateTaskAsync("Doing work...", stepContext.CancellationToken);
    
    await using (task.ConfigureAwait(false))
    {
        // Do work
        await task.CompleteAsync("Done", CompletionState.Completed, stepContext.CancellationToken);
    }
});

Affected APIs