# ContainerAppExtensions Methods

- Package: [Aspire.Hosting.Azure.AppContainers](/reference/api/csharp/aspire.hosting.azure.appcontainers.md)
- Type: [ContainerAppExtensions](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions.md)
- Kind: `Methods`
- Members: `4`

Provides extension methods for customizing Azure Container App resource.

## ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)

> **Experimental:** ASPIREACADOMAINS001 - [Learn more](/diagnostics/aspireacadomains001/)

- Name: `ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppContainers/ContainerAppExtensions.cs#L62-L127)

Configures the custom domain for the container app.

```csharp
public static class ContainerAppExtensions
{
    public static void ConfigureCustomDomain(
        this ContainerApp app,
        IResourceBuilder<ParameterResource> customDomain,
        IResourceBuilder<ParameterResource> certificateName)
    {
        // ...
    }
}
```

## Parameters

- `app` (`ContainerApp`)
  The container app resource to configure for custom domain usage.
- `customDomain` (`IResourceBuilder<ParameterResource>`)
  A resource builder for a parameter resource capturing the name of the custom domain.
- `certificateName` (`IResourceBuilder<ParameterResource>`)
  A resource builder for a parameter resource capturing the name of the certificate configured in the Azure Portal.

## Exceptions

- `ArgumentException` -- Throws if the container app resource is not parented to a `Azure.AzureResourceInfrastructure`.

## Remarks

The [ContainerAppExtensions.ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions/methods.md#configurecustomdomain-containerapp-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) extension method simplifies the process of assigning a custom domain to a container app resource when it is deployed. It has no impact on local development.

The [ContainerAppExtensions.ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions/methods.md#configurecustomdomain-containerapp-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) method is used in conjunction with the [AzureContainerAppContainerExtensions.PublishAsAzureContainerApp(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerApp>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/azurecontainerappcontainerextensions/methods.md#publishasazurecontainerapp-iresourcebuilder-t-action-azureresourceinfrastructure-containerapp) callback. Assigning a custom domain to a container app resource is a multi-step process and requires multiple deployments.

The [ContainerAppExtensions.ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions/methods.md#configurecustomdomain-containerapp-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) method takes two arguments which are parameter resource builders. The first is a parameter that represents the custom domain and the second is a parameter that represents the name of the managed certificate provisioned via the Azure Portal

When deploying with custom domains configured for the first time leave the `certificateName` parameter empty (when prompted by the Azure Developer CLI). Once the application is deployed successfully access to the Azure Portal to bind the custom domain to a managed SSL certificate. Once the certificate is successfully provisioned, subsequent deployments of the application can use this certificate name when the `certificateName` is prompted.

For deployments triggered locally by the Azure Developer CLI the `config.json` file in the `.azure/{environment name}` path can be modified with the certificate name since Azure Developer CLI will not prompt again for the value.

This example shows declaring two parameters to capture the custom domain and certificate name and passing them to the [ContainerAppExtensions.ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions/methods.md#configurecustomdomain-containerapp-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) method via the [AzureContainerAppContainerExtensions.PublishAsAzureContainerApp(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerApp>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/azurecontainerappcontainerextensions/methods.md#publishasazurecontainerapp-iresourcebuilder-t-action-azureresourceinfrastructure-containerapp) extension method.

```csharp
var builder = DistributedApplication.CreateBuilder();
var customDomain = builder.AddParameter("customDomain"); // Value provided at first deployment.
var certificateName = builder.AddParameter("certificateName"); // Value provided at second and subsequent deployments.
builder.AddProject<Projects.InventoryService>("inventory")
       .PublishAsAzureContainerApp((module, app) =>
       {
         app.ConfigureCustomDomain(customDomain, certificateName);
       });
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## PublishAsAzureContainerAppJob(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerAppJob>)

- Name: `PublishAsAzureContainerAppJob(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerAppJob>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppContainers/ContainerAppExtensions.cs#L158-L170)

Allows configuring the specified compute resource as an Azure Container App Job.

```csharp
public static class ContainerAppExtensions
{
    public static IResourceBuilder<T> PublishAsAzureContainerAppJob<T>(
        this IResourceBuilder<T> resource,
        Action<AzureResourceInfrastructure, ContainerAppJob> configure)
    {
        // ...
    }
}
```

## Parameters

- `resource` (`IResourceBuilder<T>`)
  The compute resource builder.
- `configure` (`Action<AzureResourceInfrastructure, ContainerAppJob>`)
  The configuration action for the container app job.

## Returns

`IResourceBuilder<T>` -- The updated compute resource builder.

## Remarks

This method adds the necessary infrastructure for container app jobs to the application builder and applies the specified configuration to the container app job. Note that the default trigger type for the job is set to Manual, and the default replica timeout is set to 1800 seconds (30 minutes).

```csharp
builder.AddProject<Projects.Api>.PublishAsAzureContainerAppJob((infrastructure, job) =>
{
    // Configure the container app job here
    job.Configuration.TriggerType = ContainerAppJobTriggerType.Schedule;
    job.Configuration.ScheduleTriggerConfig.CronExpression = "0 0 * * *"; // every day at midnight
});
```

This overload allows custom configuration of the container app job via a callback.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## PublishAsAzureContainerAppJob(IResourceBuilder<T>)

- Name: `PublishAsAzureContainerAppJob(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppContainers/ContainerAppExtensions.cs#L195-L201)

Configures the specified compute resource as a manually triggered Azure Container App Job.

```csharp
public static class ContainerAppExtensions
{
    public static IResourceBuilder<T> PublishAsAzureContainerAppJob<T>(
        this IResourceBuilder<T> resource)
    {
        // ...
    }
}
```

## Parameters

- `resource` (`IResourceBuilder<T>`)
  The compute resource builder.

## Returns

`IResourceBuilder<T>` -- The updated compute resource builder.

## Remarks

This is a convenience overload for the common case of manually triggered jobs. Manual trigger is the default trigger type, so this method provides a simpler API when no additional job configuration is needed.

```csharp
builder.AddProject<Projects.ProcessorJob>("processor-job")
       .PublishAsAzureContainerAppJob(); // Manual trigger (default)
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## PublishAsScheduledAzureContainerAppJob(IResourceBuilder<T>, string, Action<AzureResourceInfrastructure, ContainerAppJob>)

- Name: `PublishAsScheduledAzureContainerAppJob(IResourceBuilder<T>, string, Action<AzureResourceInfrastructure, ContainerAppJob>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppContainers/ContainerAppExtensions.cs#L244-L253)

Configures the specified compute resource as a scheduled Azure Container App Job with the provided cron expression.

```csharp
public static class ContainerAppExtensions
{
    public static IResourceBuilder<T> PublishAsScheduledAzureContainerAppJob<T>(
        this IResourceBuilder<T> resource,
        string cronExpression,
        Action<AzureResourceInfrastructure, ContainerAppJob>? configure = null)
    {
        // ...
    }
}
```

## Parameters

- `resource` (`IResourceBuilder<T>`)
  The compute resource builder.
- `cronExpression` (`string`)
  The cron expression that defines the schedule for the job.
- `configure` (`Action<AzureResourceInfrastructure, ContainerAppJob>`) `optional`
  The configuration action for the container app job.

## Returns

`IResourceBuilder<T>` -- The updated compute resource builder.

## Remarks

This method is a convenience wrapper around [ContainerAppExtensions.PublishAsAzureContainerAppJob(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerAppJob>)](/reference/api/csharp/aspire.hosting.azure.appcontainers/containerappextensions/methods.md#publishasazurecontainerappjob-iresourcebuilder-t-action-azureresourceinfrastructure-containerappjob) that automatically configures the job with a schedule trigger using the specified cron expression.

```csharp
builder.AddProject<Projects.ProcessorJob>("job")
       .PublishAsScheduledAzureContainerAppJob("0 0 * * *"); // Run every day at midnight
```

This overload allows custom configuration of the scheduled container app job via a callback.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
