Share via


ContainerAppExtensions.ConfigureCustomDomain Method

Definition

Configures the custom domain for the container app.

public static void ConfigureCustomDomain (this Azure.Provisioning.AppContainers.ContainerApp app, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> customDomain, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> certificateName);
static member ConfigureCustomDomain : Azure.Provisioning.AppContainers.ContainerApp * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> -> unit
<Extension()>
Public Sub ConfigureCustomDomain (app As ContainerApp, customDomain As IResourceBuilder(Of ParameterResource), certificateName As IResourceBuilder(Of ParameterResource))

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 certficate configured in the Azure Portal.

Exceptions

Throws if the container app resource is not parented to a AzureResourceInfrastructure.

Examples

This example shows declaring two parameters to capture the custom domain and certificate name and passing them to the ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) method via the PublishAsAzureContainerApp<T>(IResourceBuilder<T>, Action<AzureResourceInfrastructure,ContainerApp>) 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);
       });

Remarks

The 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 ConfigureCustomDomain(ContainerApp, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) method is used in conjunction with the PublishAsAzureContainerApp<T>(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 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 applicatio is deployed acucessfully 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.

Applies to