Skip to content

Deploy Aspire to Azure Container Apps using the Aspire CLI

When you deploy Aspire applications to Azure Container Apps using the aspire deploy command, the platform provides several deployment options and configurations. This guide explains how to use the Aspire CLI to deploy your applications to Azure Container Apps with various configuration options.

The aspire deploy command is currently in preview and must be explicitly enabled. Enable the feature by setting the following environment variable:

Terminal window
export DOTNET_ASPIRE_ENABLE_DEPLOY_COMMAND=true

Before deploying your application, authenticate with Azure using the Azure CLI:

Authenticate with Azure CLI
az login

This command opens a browser window for you to sign in to your Azure account. After authentication completes, you can proceed with deployment.

If you don’t already have an Aspire project, create one using the Aspire CLI:

Create new Aspire project
aspire new AspireApp
cd AspireApp

This creates a new solution with an AppHost project and a sample web frontend.

Deploy your application to Azure Container Apps using the aspire deploy command:

Deploy to Azure Container Apps
aspire deploy

The command performs the following steps:

  1. Validates your configuration: Checks for required settings and dependencies.

  2. Generates the deployment manifest: Creates a manifest describing all resources in your application.

  3. Provisions Azure resources: Creates or updates Azure Container Apps, Container Registry, and other required resources.

  4. Builds and pushes container images: Builds Docker images for your projects and pushes them to Azure Container Registry.

  5. Deploys the application: Updates your Container Apps with the new images and configuration.

You can provide deployment parameters inline using the --deployment-param flag:

Deploy with parameters
aspire deploy --deployment-param location=eastus --deployment-param environment=production

For complex deployments, create a parameters file:

deployment-params.json
{
"location": "eastus",
"environment": "production",
"resourceGroupName": "my-aspire-app-rg"
}

Then reference the file during deployment:

Deploy with parameters file
aspire deploy --deployment-params-file deployment-params.json

During deployment, the CLI displays progress information:

Deployment progress output
Building projects...
✓ AspireApp.Web
✓ AspireApp.ApiService
Pushing images to registry...
✓ aspireapp-web:latest
✓ aspireapp-apiservice:latest
Provisioning Azure resources...
✓ Resource group: aspireapp-rg
✓ Container Registry: aspireappacr
✓ Container Apps Environment: aspireapp-env
✓ Container App: web
✓ Container App: apiservice
Deployment complete!
Web endpoint: https://web.proudriver-12345678.eastus.azurecontainerapps.io

After deployment completes, monitor your application using several methods:

View container logs
az containerapp logs show --name web --resource-group aspireapp-rg --follow

Navigate to the Azure portal to:

  • View application metrics and logs
  • Configure scaling rules
  • Manage environment variables and secrets
  • Monitor application health

For comprehensive monitoring, integrate Application Insights:

AppHost.cs - Add Application Insights
var builder = DistributedApplication.CreateBuilder(args);
var appInsights = builder.AddAzureApplicationInsights("monitoring");
builder.AddProject<Projects.AspireApp_Web>("web")
.WithReference(appInsights);
builder.AddProject<Projects.AspireApp_ApiService>("apiservice")
.WithReference(appInsights);
builder.Build().Run();

If you encounter authentication errors:

  1. Verify you’re logged in to Azure:

    Check Azure login status
    az account show
  2. Ensure you have the correct subscription selected:

    Set Azure subscription
    az account set --subscription <subscription-id>
  3. Verify your account has the necessary permissions to create resources in the target resource group.

If container image builds fail:

  • Ensure Docker Desktop or Podman is running
  • Check that your Dockerfile syntax is correct
  • Verify you have sufficient disk space for image builds

If the deployment fails:

  • Check the error message for specific details
  • Verify your deployment parameters are correct
  • Ensure the target region supports Azure Container Apps
  • Check Azure service health for any outages

To remove all deployed resources:

Delete resource group
az group delete --name aspireapp-rg --yes --no-wait
FAQCollaborateCommunityDiscussWatch