# ListmonkBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.Listmonk](/reference/api/csharp/communitytoolkit.aspire.hosting.listmonk.md)
- Type: [ListmonkBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.listmonk/listmonkbuilderextensions.md)
- Kind: `Methods`
- Members: `16`

Provides extension methods for adding listmonk resources to the application model.

<a id="addlistmonk"></a>
<a id="addlistmonk-idistributedapplicationbuilder-string-int"></a>

## AddListmonk(IDistributedApplicationBuilder, string, int?)

- Name: `AddListmonk(IDistributedApplicationBuilder, string, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L60-L72)

Adds a listmonk container resource to the application model. The default image is and the tag is .

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> AddListmonk(
        this IDistributedApplicationBuilder builder,
        string name,
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `port` (`int?`) `optional`
  The host port for the listmonk HTTP endpoint. If `null`, Aspire will assign a random host port.

## Returns

`IResourceBuilder<ListmonkResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add a listmonk container to the application model and reference it in a .NET project.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddPostgres("postgres")
  .AddDatabase("db");
var listmonk = builder.AddListmonk("listmonk")
  .WithReference(db);
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(listmonk);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withadmincredentials"></a>
<a id="withadmincredentials-iresourcebuilder-listmonkresource-string-iresourcebuilder-parameterresource"></a>

## WithAdminCredentials(IResourceBuilder<ListmonkResource>, string, IResourceBuilder<ParameterResource>)

- Name: `WithAdminCredentials(IResourceBuilder<ListmonkResource>, string, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L249-L255)

Configures the first-run listmonk Super Admin credentials.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithAdminCredentials(
        this IResourceBuilder<ListmonkResource> builder,
        string username,
        IResourceBuilder<ParameterResource> password)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `username` (`string`)
  The value for `LISTMONK_ADMIN_USER`.
- `password` (`IResourceBuilder<ParameterResource>`)
  The parameter resource used for `LISTMONK_ADMIN_PASSWORD`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withadminpassword"></a>
<a id="withadminpassword-iresourcebuilder-listmonkresource-iresourcebuilder-parameterresource"></a>

## WithAdminPassword(IResourceBuilder<ListmonkResource>, IResourceBuilder<ParameterResource>)

- Name: `WithAdminPassword(IResourceBuilder<ListmonkResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L230-L233)

Configures the first-run listmonk Super Admin password.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithAdminPassword(
        this IResourceBuilder<ListmonkResource> builder,
        IResourceBuilder<ParameterResource> password)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `password` (`IResourceBuilder<ParameterResource>`)
  The parameter resource used for `LISTMONK_ADMIN_PASSWORD`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withadminuser"></a>
<a id="withadminuser-iresourcebuilder-listmonkresource-string"></a>

## WithAdminUser(IResourceBuilder<ListmonkResource>, string)

- Name: `WithAdminUser(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L215-L218)

Configures the first-run listmonk Super Admin username.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithAdminUser(
        this IResourceBuilder<ListmonkResource> builder,
        string username)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `username` (`string`)
  The value for `LISTMONK_ADMIN_USER`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withappaddress"></a>
<a id="withappaddress-iresourcebuilder-listmonkresource-string"></a>

## WithAppAddress(IResourceBuilder<ListmonkResource>, string)

- Name: `WithAppAddress(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L84-L87)

Configures the listmonk web server address.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithAppAddress(
        this IResourceBuilder<ListmonkResource> builder,
        string address)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `address` (`string`)
  The address value for `LISTMONK_app__address`, for example `0.0.0.0:9000`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabasemaxidleconnections"></a>
<a id="withdatabasemaxidleconnections-iresourcebuilder-listmonkresource-int"></a>

## WithDatabaseMaxIdleConnections(IResourceBuilder<ListmonkResource>, int)

- Name: `WithDatabaseMaxIdleConnections(IResourceBuilder<ListmonkResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L155-L158)

Configures the maximum number of idle PostgreSQL connections.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithDatabaseMaxIdleConnections(
        this IResourceBuilder<ListmonkResource> builder,
        int maxIdle)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `maxIdle` (`int`)
  The value for `LISTMONK_db__max_idle`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabasemaxlifetime"></a>
<a id="withdatabasemaxlifetime-iresourcebuilder-listmonkresource-string"></a>

## WithDatabaseMaxLifetime(IResourceBuilder<ListmonkResource>, string)

- Name: `WithDatabaseMaxLifetime(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L170-L173)

Configures the maximum lifetime for PostgreSQL connections.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithDatabaseMaxLifetime(
        this IResourceBuilder<ListmonkResource> builder,
        string maxLifetime)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `maxLifetime` (`string`)
  The duration value for `LISTMONK_db__max_lifetime`, for example `300s`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabasemaxopenconnections"></a>
<a id="withdatabasemaxopenconnections-iresourcebuilder-listmonkresource-int"></a>

## WithDatabaseMaxOpenConnections(IResourceBuilder<ListmonkResource>, int)

- Name: `WithDatabaseMaxOpenConnections(IResourceBuilder<ListmonkResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L140-L143)

Configures the maximum number of open PostgreSQL connections.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithDatabaseMaxOpenConnections(
        this IResourceBuilder<ListmonkResource> builder,
        int maxOpen)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `maxOpen` (`int`)
  The value for `LISTMONK_db__max_open`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabaseparameters"></a>
<a id="withdatabaseparameters-iresourcebuilder-listmonkresource-string"></a>

## WithDatabaseParameters(IResourceBuilder<ListmonkResource>, string)

- Name: `WithDatabaseParameters(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L185-L188)

Configures additional PostgreSQL DSN parameters.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithDatabaseParameters(
        this IResourceBuilder<ListmonkResource> builder,
        string parameters)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `parameters` (`string`)
  The space-separated parameter string for `LISTMONK_db__params`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabasesslmode"></a>
<a id="withdatabasesslmode-iresourcebuilder-listmonkresource-string"></a>

## WithDatabaseSslMode(IResourceBuilder<ListmonkResource>, string)

- Name: `WithDatabaseSslMode(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L125-L128)

Configures the PostgreSQL SSL mode used by listmonk.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithDatabaseSslMode(
        this IResourceBuilder<ListmonkResource> builder,
        string sslMode)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `sslMode` (`string`)
  The PostgreSQL SSL mode value for `LISTMONK_db__ssl_mode`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withgroupid"></a>
<a id="withgroupid-iresourcebuilder-listmonkresource-int"></a>

## WithGroupId(IResourceBuilder<ListmonkResource>, int)

- Name: `WithGroupId(IResourceBuilder<ListmonkResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L282-L285)

Configures the group ID used by the listmonk container entrypoint.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithGroupId(
        this IResourceBuilder<ListmonkResource> builder,
        int groupId)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `groupId` (`int`)
  The value for `PGID`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withreference"></a>
<a id="withreference-iresourcebuilder-listmonkresource-iresourcebuilder-postgresdatabaseresource"></a>

## WithReference(IResourceBuilder<ListmonkResource>, IResourceBuilder<PostgresDatabaseResource>)

- Name: `WithReference(IResourceBuilder<ListmonkResource>, IResourceBuilder<PostgresDatabaseResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L101-L113)

References a `ApplicationModel.PostgresDatabaseResource` as the PostgreSQL database for the listmonk resource.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithReference(
        this IResourceBuilder<ListmonkResource> builder,
        IResourceBuilder<PostgresDatabaseResource> database)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `database` (`IResourceBuilder<PostgresDatabaseResource>`)
  The PostgreSQL database resource builder.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withtimezone"></a>
<a id="withtimezone-iresourcebuilder-listmonkresource-string"></a>

## WithTimeZone(IResourceBuilder<ListmonkResource>, string)

- Name: `WithTimeZone(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L200-L203)

Configures the time zone used by the listmonk container.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithTimeZone(
        this IResourceBuilder<ListmonkResource> builder,
        string timeZone)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `timeZone` (`string`)
  The time zone value for `TZ`, for example `Etc/UTC`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withuploadsbindmount"></a>
<a id="withuploadsbindmount-iresourcebuilder-listmonkresource-string"></a>

## WithUploadsBindMount(IResourceBuilder<ListmonkResource>, string)

- Name: `WithUploadsBindMount(IResourceBuilder<ListmonkResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L311-L314)

Adds a bind mount for listmonk media uploads.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithUploadsBindMount(
        this IResourceBuilder<ListmonkResource> builder,
        string source)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `source` (`string`)
  The source directory on the host to mount into the container.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withuploadsvolume"></a>
<a id="withuploadsvolume-iresourcebuilder-listmonkresource-string"></a>

## WithUploadsVolume(IResourceBuilder<ListmonkResource>, string?)

- Name: `WithUploadsVolume(IResourceBuilder<ListmonkResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L297-L299)

Adds a named volume for listmonk media uploads.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithUploadsVolume(
        this IResourceBuilder<ListmonkResource> builder,
        string? name = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withuserid"></a>
<a id="withuserid-iresourcebuilder-listmonkresource-int"></a>

## WithUserId(IResourceBuilder<ListmonkResource>, int)

- Name: `WithUserId(IResourceBuilder<ListmonkResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ListmonkResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9c2addac6f527ef2e33712d290b84574b455a3b/src/CommunityToolkit.Aspire.Hosting.Listmonk/ListmonkBuilderExtensions.cs#L267-L270)

Configures the user ID used by the listmonk container entrypoint.

```csharp
public static class ListmonkBuilderExtensions
{
    public static IResourceBuilder<ListmonkResource> WithUserId(
        this IResourceBuilder<ListmonkResource> builder,
        int userId)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<ListmonkResource>`)
  The listmonk resource builder.
- `userId` (`int`)
  The value for `PUID`.

## Returns

`IResourceBuilder<ListmonkResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
