콘텐츠로 이동
문서Aspire 사용해 보기
문서사용해 보기

Deploy to Azure Container Apps

이 콘텐츠는 아직 번역되지 않았습니다.

Use aspire deploy to deploy Aspire applications to Azure Container Apps. Aspire provisions the Container Apps environment, Azure Container Registry, managed identity, and the Container Apps resources needed for the compute resources in your AppHost.

Start with Deploy to Azure for the shared Azure deployment model and target selection. If you need to keep an existing azd deployment workflow, see Use existing azd workflows.

By default, local deployment uses Azure CLI credentials. Authenticate with Azure CLI before deploying:

Authenticate with Azure CLI
az login

Configure your AppHost for Azure Container Apps

Section titled “Configure your AppHost for Azure Container Apps”

Add Azure Container Apps support to your AppHost:

Aspire CLI — Add Azure App Containers
aspire add azure-appcontainers

The Aspire CLI adds the 📦 Aspire.Hosting.Azure.AppContainers integration to your AppHost. If prompted, select the matching package result.

Learn more about the aspire add command in the reference docs.

Then add the Azure Container Apps environment in your AppHost and a web app you want to place in that environment:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("aca-env");
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addDockerfile(name: string, contextPath: string, options?: {
dockerfilePath?: string;
stage?: string;
}): ContainerResource (+1 overload)

Adds a Dockerfile to the application model that can be treated like a container resource.

addDockerfile
("web", "./web")
.
ContainerResource.withHttpEndpoint(options?: {
port?: number;
targetPort?: number;
name?: string;
env?: string;
isProxied?: boolean;
} | undefined): ContainerResource (+1 overload)

Adds an HTTP endpoint

withHttpEndpoint
({
port?: number | undefined
port
: 8080,
targetPort?: number | undefined
targetPort
: 8080,
name?: string | undefined
name
: "http" })
.
ContainerResource.withExternalHttpEndpoints(): ContainerResource

Marks existing http or https endpoints on a resource as external.

withExternalHttpEndpoints
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

For a standard Azure Container Apps deployment, you only need the environment and the app resource. Use PublishAsAzureContainerApp only when you want to customize the generated Container App resource.

For general Azure resource customization such as naming, existing resources, role assignments, and outputs, see Customize Azure resources. For environment configuration, see Configure Azure Container Apps environments.

How Aspire maps your app to Azure Container Apps

Section titled “How Aspire maps your app to Azure Container Apps”

Compute resources assigned to an Azure Container Apps environment are deployed to Azure Container Apps. If one AppHost uses multiple Azure environments, assign each resource to the environment you want it to use.

Start with the common cases:

AppHost endpoint shapeAzure Container Apps result
One external HTTP endpointOne public HTTP ingress, exposed through the platform HTTPS endpoint by default
One internal HTTP endpointOne internal-only HTTP ingress inside the Container Apps environment
One TCP endpointOne TCP ingress

Aspire groups endpoints by target port before it generates Azure Container Apps ingress settings. In practice, that means:

  • Azure Container Apps supports http, http2, and tcp transports for deployment.
  • One HTTP or HTTP/2 target-port group becomes the main ingress.
  • The environment can host both internal and external endpoints.
  • HTTP and TCP traffic can’t share the same target port.

Azure Container Apps uses an Envoy-based HTTP edge proxy for HTTP ingress:

  • public HTTP-style ingress is exposed through the platform HTTPS endpoint by default
  • HTTP requests sent to the app are redirected to HTTPS

To match the deployed serving scheme, Aspire upgrades external HTTP endpoints in an Azure Container Apps environment to HTTPS when it generates endpoint URLs and service discovery connection strings for dependent resources. If you intentionally need generated endpoint URLs and connection strings to preserve http://, disable the upgrade on the environment:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("aca-env")
.
AzureContainerAppEnvironmentResource.withHttpsUpgrade(upgrade?: boolean): AzureContainerAppEnvironmentResource (+1 overload)

Configures whether HTTP endpoints should be upgraded to HTTPS in Azure Container Apps. By default, HTTP endpoints are upgraded to HTTPS for security and WebSocket compatibility.

withHttpsUpgrade
(false);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addDockerfile(name: string, contextPath: string, options?: {
dockerfilePath?: string;
stage?: string;
}): ContainerResource (+1 overload)

Adds a Dockerfile to the application model that can be treated like a container resource.

addDockerfile
("web", "./web")
.
ContainerResource.withHttpEndpoint(options?: {
port?: number;
targetPort?: number;
name?: string;
env?: string;
isProxied?: boolean;
} | undefined): ContainerResource (+1 overload)

Adds an HTTP endpoint

withHttpEndpoint
({
port?: number | undefined
port
: 8080,
targetPort?: number | undefined
targetPort
: 8080,
name?: string | undefined
name
: "http" })
.
ContainerResource.withExternalHttpEndpoints(): ContainerResource

Marks existing http or https endpoints on a resource as external.

withExternalHttpEndpoints
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Disabling the upgrade primarily affects generated endpoint configuration for dependent resources. Azure Container Apps can still redirect HTTP requests to HTTPS after deployment.

Most apps map cleanly from one endpoint group to one ingress. When an app exposes more than one endpoint group, keep these rules in mind:

  • each app gets one HTTP ingress
  • additional endpoint groups are published as additional TCP ports
  • built-in HTTP ingress features apply only to the main HTTP ingress
  • external non-HTTP endpoints aren’t supported
  • Azure Container Apps supports up to five additional ports per app

When you deploy to Azure Container Apps, Aspire translates both named volumes and bind mounts into Azure Files-backed mounts in the Container Apps environment.

  • Aspire provisions Azure Storage file shares and managed environment storage entries for the mounts used by deployed resources.
  • Both named volumes and bind mounts become mounted Azure Files shares in the deployed app.
  • A bind mount’s local host path isn’t preserved as a host bind mount in Azure deployment.

Use these mounts as persistent storage for the deployed app, not as a way to project files from the AppHost machine into the deployed environment.

During aspire deploy, Aspire:

  • provisions or attaches an Azure Container Registry
  • builds container images for the compute resources in the environment
  • pushes those images to the registry
  • creates a user-assigned managed identity
  • grants the deployed Container Apps permission to pull images

This lets Container Apps pull deployed images without manual registry credentials.

Probe traffic stays on the internal container network. If a probe is associated with an ingress-enabled endpoint, Aspire still configures the probe against the container target port instead of sending probe traffic through Container Apps ingress.

Use PublishAsAzureContainerApp when you want to customize the generated Container App resource for a project, container, or executable. It isn’t required for a standard Container Apps deployment.

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("env");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.publishAsAzureContainerApp(configure: (arg1: AzureResourceInfrastructure, arg2: ContainerApp) => Promise<void>): ProjectResource

Allows configuring the specified project resource as a container app.

publishAsAzureContainerApp
(async (
_infrastructure: AzureResourceInfrastructure
_infrastructure
,
_app: ContainerApp
_app
) => {
// Customize the generated Container App here.
});
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Use ConfigureCustomDomain when you want Aspire to configure a custom domain and managed certificate on the generated Container App.

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const customDomain: ParameterResource
customDomain
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("customDomain");
const
const certificateName: ParameterResource
certificateName
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("certificateName");
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("env");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.publishAsAzureContainerApp(configure: (arg1: AzureResourceInfrastructure, arg2: ContainerApp) => Promise<void>): ProjectResource

Allows configuring the specified project resource as a container app.

publishAsAzureContainerApp
(async (
_infrastructure: AzureResourceInfrastructure
_infrastructure
,
app: ContainerApp
app
) => {
await
app: ContainerApp
app
.
ContainerApp.configureCustomDomain(customDomain: string | ParameterResource, certificateName: string | ParameterResource): void

Configures the custom domain for the container app.

configureCustomDomain
(
const customDomain: ParameterResource
customDomain
,
const certificateName: ParameterResource
certificateName
);
});
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Services deployed to Azure Container Apps use internal DNS for service discovery. Use WithExternalHttpEndpoints() only for endpoints you want reachable outside the Container Apps environment.

apphost.mts
const api = await builder.addProject("api", "../Api/Api.csproj", "http");
await api.withExternalHttpEndpoints();

By default, Aspire provisions an Azure Container Registry for the environment. If you want to use a shared or explicitly named registry instead, add an Azure Container Registry resource and attach it to the environment:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const acr: AzureContainerRegistryResource
acr
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerRegistry(name: string): AzureContainerRegistryResource

Adds an Azure Container Registry resource to the application model.

addAzureContainerRegistry
("shared-acr");
const
const env: AzureContainerAppEnvironmentResource
env
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("aspire-env");
await
const env: AzureContainerAppEnvironmentResource
env
.
AzureBicepResource.withAzureContainerRegistry(registryBuilder: AzureContainerRegistryResource): AzureContainerAppEnvironmentResource

Configures a compute environment resource to use an Azure Container Registry.

withAzureContainerRegistry
(
const acr: AzureContainerRegistryResource
acr
);

For more information, see Azure Container Registry integration.

The Azure Container Apps environment includes the Aspire Dashboard by default. It helps you inspect the compute resources deployed into that environment. Managed Azure backing services aren’t shown as dashboard resources there. If you don’t want to deploy it, disable it on the environment:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const env: AzureContainerAppEnvironmentResource
env
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("aspire-env");
await
const env: AzureContainerAppEnvironmentResource
env
.
AzureContainerAppEnvironmentResource.withDashboard(enable?: boolean): AzureContainerAppEnvironmentResource (+1 overload)

Configures whether the Aspire dashboard should be included in the container app environment.

withDashboard
(false);

Once your AppHost is configured, deploy it with:

Deploy to Azure Container Apps
aspire deploy

Aspire can prompt for missing Azure settings and AppHost parameters during an interactive deploy, then provisions and deploys the Container Apps resources behind the scenes.

For Azure authentication, shared Azure settings, and Parameters__* inputs, see Deploy to Azure and Environments.

After deployment, use the dashboard URL in the CLI output, the Azure portal, or az containerapp show to inspect the deployed compute resources and application URLs.

To tear down deployed resources, use aspire destroy. The command discovers the deployment, lists the Azure resources it will remove, and prompts for confirmation before deleting the resource group:

Aspire CLI - Destroy the deployed environment
aspire destroy