Skip to content
Docs Try Aspire

ContainerAppExtensions Methods

Class Methods 4 members
Provides extension methods for customizing Azure Container App resource.
ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) Section titled ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) extension
Configures the custom domain for the container app.
public static class ContainerAppExtensions
{
public static void ConfigureCustomDomain(
this ContainerApp app,
IResourceBuilder<ParameterResource> customDomain,
IResourceBuilder<ParameterResource> certificateName)
{
// ...
}
}
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.
ArgumentException Throws if the container app resource is not parented to a Azure.AzureResourceInfrastructure.

The ContainerAppExtensions.ConfigureCustomDomain 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 method is used in conjunction with the AzureContainerAppContainerExtensions.PublishAsAzureContainerApp callback. Assigning a custom domain to a container app resource is a multi-step process and requires multiple deployments.

The ContainerAppExtensions.ConfigureCustomDomain 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 by 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 method via the AzureContainerAppContainerExtensions.PublishAsAzureContainerApp extension method.
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);
});
PublishAsAzureContainerAppJob(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerAppJob>) Section titled PublishAsAzureContainerAppJob(IResourceBuilder<T>, Action<AzureResourceInfrastructure, ContainerAppJob>) extension IResourceBuilder<T>
Allows configuring the specified compute resource as an Azure Container App Job.
public static class ContainerAppExtensions
{
public static IResourceBuilder<T> PublishAsAzureContainerAppJob<T>(
this IResourceBuilder<T> resource,
Action<AzureResourceInfrastructure, ContainerAppJob> configure)
{
// ...
}
}
resource IResourceBuilder<T> The compute resource builder.
configure Action<AzureResourceInfrastructure, ContainerAppJob> The configuration action for the container app job.
IResourceBuilder<T> The updated compute resource builder.
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).
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
});
PublishAsAzureContainerAppJob(IResourceBuilder<T>) Section titled PublishAsAzureContainerAppJob(IResourceBuilder<T>) extension IResourceBuilder<T>
Configures the specified compute resource as a manually triggered Azure Container App Job.
public static class ContainerAppExtensions
{
public static IResourceBuilder<T> PublishAsAzureContainerAppJob<T>(
this IResourceBuilder<T> resource)
{
// ...
}
}
resource IResourceBuilder<T> The compute resource builder.
IResourceBuilder<T> The updated compute resource builder.
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.
builder.AddProject<Projects.ProcessorJob>("processor-job")
.PublishAsAzureContainerAppJob(); // Manual trigger (default)
PublishAsScheduledAzureContainerAppJob(IResourceBuilder<T>, string, Action<AzureResourceInfrastructure, ContainerAppJob>) Section titled PublishAsScheduledAzureContainerAppJob(IResourceBuilder<T>, string, Action<AzureResourceInfrastructure, ContainerAppJob>) extension IResourceBuilder<T>
Configures the specified compute resource as a scheduled Azure Container App Job with the provided cron expression.
public static class ContainerAppExtensions
{
public static IResourceBuilder<T> PublishAsScheduledAzureContainerAppJob<T>(
this IResourceBuilder<T> resource,
string cronExpression,
Action<AzureResourceInfrastructure, ContainerAppJob>? configure = null)
{
// ...
}
}
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.
IResourceBuilder<T> The updated compute resource builder.
This method is a convenience wrapper around ContainerAppExtensions.PublishAsAzureContainerAppJob that automatically configures the job with a schedule trigger using the specified cron expression.
builder.AddProject<Projects.ProcessorJob>("job")
.PublishAsScheduledAzureContainerAppJob(
"0 0 * * *"); // Run every day at midnight