# DbxBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.Dbx](/reference/api/csharp/communitytoolkit.aspire.hosting.dbx.md)
- Type: [DbxBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.dbx/dbxbuilderextensions.md)
- Kind: `Methods`
- Members: `2`

Provides extension methods for dbx resources to an `Hosting.IDistributedApplicationBuilder`.

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

## AddDbx(IDistributedApplicationBuilder, string, int?)

- Name: `AddDbx(IDistributedApplicationBuilder, string, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<DbxContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.Dbx/DbxBuilderExtensions.cs#L46-L96)

Adds a dbx container resource to the application.

```csharp
public static class DbxBuilderExtensions
{
    public static IResourceBuilder<DbxContainerResource> AddDbx(
        this IDistributedApplicationBuilder builder,
        string name = "dbx",
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The resource builder.
- `name` (`string`) `optional`
  The name of the resource. This name will be used as the connection string name when referenced in a dependency. Optional; defaults to `dbx`.
- `port` (`int?`) `optional`
  The host port to bind the underlying container to.

## Returns

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

## Remarks

Multiple [DbxBuilderExtensions.AddDbx(IDistributedApplicationBuilder, string, int?)](/reference/api/csharp/communitytoolkit.aspire.hosting.dbx/dbxbuilderextensions/methods.md#adddbx-idistributedapplicationbuilder-string-int) calls will return the same resource builder instance.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withhostport"></a>
<a id="withhostport-iresourcebuilder-dbxcontainerresource-int"></a>

## WithHostPort(IResourceBuilder<DbxContainerResource>, int?)

- Name: `WithHostPort(IResourceBuilder<DbxContainerResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<DbxContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.Dbx/DbxBuilderExtensions.cs#L25-L30)

Configures the host port that the dbx resource is exposed on instead of using randomly assigned port.

```csharp
public static class DbxBuilderExtensions
{
    public static IResourceBuilder<DbxContainerResource> WithHostPort(
        this IResourceBuilder<DbxContainerResource> builder,
        int? port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<DbxContainerResource>`)
  The resource builder for dbx.
- `port` (`int?`)
  The port to bind on the host. If `null` is used random port will be assigned.

## Returns

`IResourceBuilder<DbxContainerResource>` -- The resource builder for dbx.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
