Skip to main content

aspire deploy

Deploy an AppHost to its deployment targets. (Preview)

Usage

aspire deploy [options]

Description

The aspire deploy command deploys your Aspire application to cloud environments like Azure Container Apps, Azure Kubernetes Service (AKS), or Kubernetes. It generates deployment manifests, provisions infrastructure, and deploys your services.
The aspire deploy command is currently in preview and under active development.

What it Does

  1. Builds the AppHost - Compiles your AppHost project
  2. Generates manifests - Creates deployment manifests based on your AppHost configuration
  3. Provisions infrastructure - Creates cloud resources (containers, databases, message queues)
  4. Deploys services - Publishes and deploys your containerized services
  5. Configures networking - Sets up ingress, service discovery, and communication
  6. Manages secrets - Securely handles connection strings and credentials

Options

--apphost
string
The path to the Aspire AppHost project fileExample: --apphost ./src/MyApp.AppHost/MyApp.AppHost.csprojIf not specified, the CLI searches for an AppHost project in the current directory and parent directories.
--output-path
string
The optional output path for deployment artifactsExample: --output-path ./deployDeployment artifacts include manifests, Dockerfiles, and configuration files.
--environment
string
The deployment environment nameExample: --environment ProductionThis maps to ASP.NET Core environment names and can be used to configure environment-specific settings.
--log-level
string
Set the logging verbosity levelOptions: Trace, Debug, Information, Warning, Error, CriticalExample: --log-level Debug
--include-exception-details
boolean
Include exception details in error messagesExample: --include-exception-detailsUseful for debugging deployment failures.
--clear-cache
boolean
Clear the deployment cache and do not save deployment stateExample: --clear-cacheForces a fresh deployment without using cached state.

Examples

Deploy to default target

aspire deploy
Output:
✓ Building AppHost...
✓ Generating deployment manifests...
✓ Provisioning infrastructure...
✓ Deploying services...
✓ DEPLOYMENT COMPLETED

Deployment completed successfully.

Deploy to a specific environment

aspire deploy --environment Production
This sets ASPNETCORE_ENVIRONMENT=Production, which can be used to:
  • Load environment-specific appsettings.Production.json files
  • Configure production database connection strings
  • Enable/disable features based on environment

Deploy with artifacts output

aspire deploy --output-path ./deploy
This generates deployment artifacts in the ./deploy directory:
deploy/
├── manifest.json
├── MyApp.ApiService/
│   └── Dockerfile
├── MyApp.Web/
│   └── Dockerfile
└── infrastructure/
    └── azure-resources.bicep

Deploy with debug logging

aspire deploy --log-level Debug --include-exception-details
Useful for troubleshooting deployment issues.

Force a clean deployment

aspire deploy --clear-cache
Clears cached state and performs a fresh deployment.

Deployment Targets

Azure Container Apps

Deploy to Azure Container Apps for a fully managed serverless container platform:
aspire deploy
Requires:
  • Azure subscription
  • Azure CLI (az) installed and authenticated
  • Azure Container Apps extension
The deployment creates:
  • Container Apps Environment
  • Container Apps for each service
  • Azure Container Registry for images
  • Managed identities for services
  • Azure resources for integrations (Redis, PostgreSQL, etc.)

Azure Kubernetes Service (AKS)

Deploy to AKS for full Kubernetes control:
aspire deploy
Requires:
  • Azure subscription
  • Azure CLI (az) installed and authenticated
  • kubectl installed
  • AKS cluster created
The deployment creates:
  • Kubernetes deployments
  • Kubernetes services
  • Ingress configurations
  • ConfigMaps and Secrets

Kubernetes

Deploy to any Kubernetes cluster:
aspire deploy
Requires:
  • kubectl configured with cluster access
  • Docker registry for images
The deployment generates standard Kubernetes YAML manifests.

Deployment Manifest

The aspire deploy command generates a deployment manifest from your AppHost. The manifest describes:
  • Projects - .NET services to containerize and deploy
  • Containers - Pre-built container images to deploy
  • Resources - Infrastructure dependencies (databases, caches, queues)
  • Connections - Service-to-service references and connection strings
  • Endpoints - HTTP/HTTPS ingress configuration
You can view the manifest without deploying:
aspire publish --output-path ./manifests
cat ./manifests/manifest.json

Environment Variables

Deployment injects environment variables for:
  • Connection strings - Database, cache, and message queue connections
  • Service discovery - URLs for referenced services
  • Configuration - AppHost-defined environment variables
Example in deployed service:
ConnectionStrings__redis=redis:6379
services__api__http__0=https://api.myapp.com

Secrets Management

The deployment automatically:
  • Extracts connection strings and secrets from your AppHost
  • Stores them securely in the target platform (Azure Key Vault, Kubernetes Secrets)
  • Injects them as environment variables at runtime
  • Never includes secrets in deployment manifests

Deployment State

The CLI maintains deployment state to enable:
  • Incremental updates (only changed resources)
  • Resource cleanup on redeploy
  • Environment isolation
State is stored in:
~/.aspire/deploy/<environment>/state.json
Clear state with --clear-cache.

Troubleshooting

Deployment fails with authentication error

Ensure you’re authenticated:
az login
az account show

Services fail to start

Check logs:
az containerapp logs show --name myapp-api --resource-group myapp
Or for Kubernetes:
kubectl logs deployment/myapp-api

Connection strings are missing

Verify environment variables:
az containerapp show --name myapp-api --resource-group myapp --query properties.template.containers[0].env

Resources aren’t provisioned

Check the deployment manifest:
aspire publish --output-path ./manifests
cat ./manifests/manifest.json
Ensure your AppHost defines resources like:
var redis = builder.AddRedis("cache");
var postgres = builder.AddPostgres("postgres").AddDatabase("mydb");

Limitations (Preview)

Current preview limitations:
  • Limited to Azure and Kubernetes deployment targets
  • Some integration types may not support deployment
  • Manual cleanup of cloud resources may be required
  • Deployment state management is evolving
These limitations will be addressed as the feature moves toward general availability.

See Also

Build docs developers (and LLMs) love