Skip to content

Deploying .NET Aspire to Azure

Deploy your .NET Aspire application to Azure Container Apps in minutes using the Azure Developer CLI (azd). This guide covers the commands you need and the concepts interviewers ask about.

Required tools:

  • .NET 9.0 SDK (dotnet --version)
  • Azure Developer CLI (brew tap azure/azd && brew install azd)
  • Docker Desktop (must be running)
  • Azure CLI (optional: brew install azure-cli)

Azure account:

  • Subscription with Owner or Contributor role
  • User Access Administrator role (for managed identity assignments)
Terminal window
# Login to Azure
azd auth login
# Verify authentication
azd auth show
# Verify your project has azure.yaml (Aspire generates this)
cat azure.yaml

Your azure.yaml should reference your AppHost project — azd reads it to generate infrastructure templates.

Terminal window
# Create development environment (first time only)
azd env new dev
# Full deployment: package → provision → deploy
azd up

That’s it. azd packages your containers, provisions all Azure resources, and deploys them.

Terminal window
# Package app into containers
azd package
# Provision infrastructure only
azd provision
# Deploy app only
azd deploy
# Deploy specific service
azd deploy app
Terminal window
# Create environment
azd env new <name>
# List environments
azd env list
# Switch environment
azd env select <name>
# Set environment variable
azd env set KEY value
# View all variables
azd env get-values

Keep separate environments for dev/prod — switch between them with azd env select.

StepDevelopmentProduction
Create envazd env new devazd env new prod
Set varsMinimal — just ASPNETCORE_ENVIRONMENT=DevelopmentFull: add JWT keys, database connections, etc.
Deployazd up (infra will be rebuilt)azd up (same command, but infra is production-grade)
SecretsCan use env varsMust use Key Vault references
Teardownazd down (safe to delete daily)Never run azd down without backup
Terminal window
# Set up GitHub Actions or Azure DevOps
azd pipeline config
# Select your platform when prompted
# azd generates the workflow file automatically
Terminal window
# View deployment info
azd show
# Open monitoring dashboard
azd monitor
# Stream application logs
azd monitor --logs
# Get detailed environment info
azd env get-values

Use azd monitor to open Application Insights — critical for production debugging.

Terminal window
# Store secrets in Azure Key Vault (never in env vars for production)
azd env set KEYVAULT_NAME your-vault-name

Configure your app to read from Key Vault using managed identity:

Azure.Extensions.AspNetCore.Configuration.Secrets
var keyVaultUrl = new Uri($"https://{keyVaultName}.vault.azure.net/");
config.AddAzureKeyVault(keyVaultUrl, new DefaultAzureCredential());
Terminal window
# azd enables managed identity by default
# Your Container App gets an identity automatically
# Grant it Key Vault access in Azure Portal
# → Access Management → Add role assignment (Key Vault Secrets User)
  • Container Apps use SSL/TLS by default for data in transit
  • Cosmos DB encryption at rest is enabled automatically
  • Restrict Container Apps ingress: use internal ingress for internal services
Terminal window
# Environment management
azd env new <name> # Create environment
azd env select <name> # Switch environment
azd env set KEY value # Set variable
# Deployment
azd up # Full deployment
azd provision # Infrastructure only
azd deploy # Application only
# Monitoring
azd show # Show deployment info
azd monitor # Open Application Insights
# Infrastructure
azd infra gen # Generate Bicep files (review before prod)
azd down # Delete all resources
# CI/CD
azd pipeline config # Set up GitHub Actions / Azure DevOps
  1. Run azd auth login
  2. Run azd env new dev
  3. Run azd up (first deploy takes ~15 min)
  4. Test your app in Azure Portal or via the output endpoint
  5. For production: azd env new prod → set secrets in Key Vault → azd up
  6. Set up CI/CD: azd pipeline config
  7. Monitor logs: azd monitor --logs

Need help? Check Application Insights logs via azd monitor. For deployment failures, run azd env get-values to verify all variables are set. Still stuck? The azd team maintains excellent docs.