# PipelineStepFactoryExtensions Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [PipelineStepFactoryExtensions](/reference/api/csharp/aspire.hosting/pipelinestepfactoryextensions.md)
- Kind: `Methods`
- Members: `7`

Provides extension methods for adding pipeline steps to resources.

## WithPipelineConfiguration(IResourceBuilder<T>, Func<PipelineConfigurationContext, Task>)

- Name: `WithPipelineConfiguration(IResourceBuilder<T>, Func<PipelineConfigurationContext, Task>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Registers a callback to be executed during the pipeline configuration phase, allowing modification of step dependencies and relationships.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineConfiguration<T>(
        this IResourceBuilder<T> builder,
        Func<PipelineConfigurationContext, Task> callback)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `callback` (`Func<PipelineConfigurationContext, Task>`)
  The callback function to execute during the configuration phase.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## ATS metadata

### Ignored by ATS

- Reason: Polyglot app hosts use the synchronous Action<> overload via withPipelineConfiguration.

## WithPipelineConfiguration(IResourceBuilder<T>, Action<PipelineConfigurationContext>)

- Name: `WithPipelineConfiguration(IResourceBuilder<T>, Action<PipelineConfigurationContext>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Registers a callback to be executed during the pipeline configuration phase, allowing modification of step dependencies and relationships.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineConfiguration<T>(
        this IResourceBuilder<T> builder,
        Action<PipelineConfigurationContext> callback)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `callback` (`Action<PipelineConfigurationContext>`)
  The callback function to execute during the configuration phase.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, PipelineStep>)

- Name: `WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, PipelineStep>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Adds a pipeline step to the resource that will be executed during deployment.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineStepFactory<T>(
        this IResourceBuilder<T> builder,
        Func<PipelineStepFactoryContext, PipelineStep> factory)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `factory` (`Func<PipelineStepFactoryContext, PipelineStep>`)
  A factory function that creates the pipeline step.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## Remarks

This overload is not available in polyglot app hosts. Use the overload that takes a step name and callback instead.

## ATS metadata

### Ignored by ATS

- Reason: Polyglot callbacks can't construct and return PipelineStep instances. Use the step-name overload instead.

## WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, Task<PipelineStep>>)

- Name: `WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, Task<PipelineStep>>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Adds a pipeline step to the resource that will be executed during deployment.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineStepFactory<T>(
        this IResourceBuilder<T> builder,
        Func<PipelineStepFactoryContext, Task<PipelineStep>> factory)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `factory` (`Func<PipelineStepFactoryContext, Task<PipelineStep>>`)
  An async factory function that creates the pipeline step.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## Remarks

This overload is not available in polyglot app hosts. Use the overload that takes a step name and callback instead.

## ATS metadata

### Ignored by ATS

- Reason: Polyglot callbacks can't construct and return PipelineStep instances. Use the step-name overload instead.

## WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, IEnumerable<PipelineStep>>)

- Name: `WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, IEnumerable<PipelineStep>>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Adds multiple pipeline steps to the resource that will be executed during deployment.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineStepFactory<T>(
        this IResourceBuilder<T> builder,
        Func<PipelineStepFactoryContext, IEnumerable<PipelineStep>> factory)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `factory` (`Func<PipelineStepFactoryContext, IEnumerable<PipelineStep>>`)
  A factory function that creates multiple pipeline steps.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## Remarks

This overload is not available in polyglot app hosts. Use the overload that takes a step name and callback instead, and call it multiple times.

## ATS metadata

### Ignored by ATS

- Reason: Polyglot callbacks can't construct and return PipelineStep instances. Use the step-name overload instead.

## WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, Task<IEnumerable<PipelineStep>>>)

- Name: `WithPipelineStepFactory(IResourceBuilder<T>, Func<PipelineStepFactoryContext, Task<IEnumerable<PipelineStep>>>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs)

Adds multiple pipeline steps to the resource that will be executed during deployment.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineStepFactory<T>(
        this IResourceBuilder<T> builder,
        Func<PipelineStepFactoryContext, Task<IEnumerable<PipelineStep>>> factory)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `factory` (`Func<PipelineStepFactoryContext, Task<IEnumerable<PipelineStep>>>`)
  An async factory function that creates multiple pipeline steps.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## Remarks

This overload is not available in polyglot app hosts. Use the overload that takes a step name and callback instead, and call it multiple times.

## ATS metadata

### Ignored by ATS

- Reason: Polyglot callbacks can't construct and return PipelineStep instances. Use the step-name overload instead.

## WithPipelineStepFactory(IResourceBuilder<T>, string, Func<PipelineStepContext, Task>, string[]?, string[]?, string[]?, string?)

- Name: `WithPipelineStepFactory(IResourceBuilder<T>, string, Func<PipelineStepContext, Task>, string[]?, string[]?, string[]?, string?)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs#L113-L126)

Adds a pipeline step to the resource that will be executed during deployment.

```csharp
public static class PipelineStepFactoryExtensions
{
    public static IResourceBuilder<T> WithPipelineStepFactory<T>(
        this IResourceBuilder<T> builder,
        string stepName,
        Func<PipelineStepContext, Task> callback,
        string[]? dependsOn = null,
        string[]? requiredBy = null,
        string[]? tags = null,
        string? description = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The resource builder.
- `stepName` (`string`)
  The unique name of the pipeline step.
- `callback` (`Func<PipelineStepContext, Task>`)
  The callback to execute when the step runs.
- `dependsOn` (`string[]?`) `optional`
  Optional step names that this step depends on.
- `requiredBy` (`string[]?`) `optional`
  Optional step names that require this step.
- `tags` (`string[]?`) `optional`
  Optional tags that categorize this step.
- `description` (`string?`) `optional`
  An optional human-readable description of the step.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The resource builder for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
