Zum Inhalt springen
Docs Try Aspire
Docs Try

Deploy to Azure Container Apps

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureContainerAppEnvironment("aca-env");
builder.AddDockerfile("web", "./web")
.WithHttpEndpoint(port: 8080, targetPort: 8080, name: "http")
.WithExternalHttpEndpoints();
builder.Build().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
  • you can turn off that default upgrade behavior on the environment if you need to keep HTTP behavior

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.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureContainerAppEnvironment("env");
builder.AddProject<Projects.Api>("api")
.PublishAsAzureContainerApp((infrastructure, app) =>
{
app.Template.Scale.MinReplicas = 1;
app.Template.Scale.MaxReplicas = 10;
});
builder.Build().Run();

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

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var customDomain = builder.AddParameter("customDomain");
var certificateName = builder.AddParameter("certificateName");
builder.AddAzureContainerAppEnvironment("env");
#pragma warning disable ASPIREACADOMAINS001
builder.AddProject<Projects.Api>("api")
.PublishAsAzureContainerApp((infrastructure, app) =>
{
app.ConfigureCustomDomain(customDomain, certificateName);
});
#pragma warning restore ASPIREACADOMAINS001
builder.Build().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.cs
builder.AddProject<Projects.Api>("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.cs
var builder = DistributedApplication.CreateBuilder(args);
var acr = builder.AddAzureContainerRegistry("shared-acr");
builder.AddAzureContainerAppEnvironment("aspire-env")
.WithAzureContainerRegistry(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.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureContainerAppEnvironment("aspire-env")
.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 remove deployed resources, delete the resource group:

Delete resource group
az group delete --name <resource-group-name>