# AspireSftpExtensions Methods

- Package: [CommunityToolkit.Aspire.Sftp](/reference/api/csharp/communitytoolkit.aspire.sftp.md)
- Type: [AspireSftpExtensions](/reference/api/csharp/communitytoolkit.aspire.sftp/aspiresftpextensions.md)
- Kind: `Methods`
- Members: `2`

Provides extension methods for registering SFTP-related services in an `Hosting.IHostApplicationBuilder`.

## AddKeyedSftpClient(IHostApplicationBuilder, string, Action<SftpSettings>)

- Name: `AddKeyedSftpClient(IHostApplicationBuilder, string, Action<SftpSettings>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Sftp/AspireSftpExtensions.cs#L46-L49)

Registers `SshNet.SftpClient` as a keyed singleton for the given `name` in the services provided by the `builder`.

```csharp
public static class AspireSftpExtensions
{
    public static void AddKeyedSftpClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<SftpSettings>? configureSettings = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `name` (`string`)
  The connection name to use to find a connection string.
- `configureSettings` (`Action<SftpSettings>`) `optional`
  An optional method that can be used for customizing the [SftpSettings](/reference/api/csharp/communitytoolkit.aspire.sftp/sftpsettings.md). It's invoked after the settings are read from the configuration.

## AddSftpClient(IHostApplicationBuilder, string, Action<SftpSettings>)

- Name: `AddSftpClient(IHostApplicationBuilder, string, Action<SftpSettings>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Sftp/AspireSftpExtensions.cs#L30-L33)

Registers `SshNet.SftpClient` as a singleton in the services provided by the `builder`.

```csharp
public static class AspireSftpExtensions
{
    public static void AddSftpClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<SftpSettings>? configureSettings = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `connectionName` (`string`)
  The connection name to use to find a connection string.
- `configureSettings` (`Action<SftpSettings>`) `optional`
  An optional method that can be used for customizing the [SftpSettings](/reference/api/csharp/communitytoolkit.aspire.sftp/sftpsettings.md). It's invoked after the settings are read from the configuration.
