9 Deploying Aspire apps to production
The chapter explains how to move a .NET Aspire application from local development into production with confidence by making a few important design adjustments first. It shows how to plan for realistic deployment needs such as multiple replicas for busy services, different behaviors for local versus cloud environments, automated database migrations, and extra operational commands in the dashboard. These changes make the system easier to scale, maintain, and operate once it is live.
It then describes how Aspire applications are prepared for deployment by generating a manifest that captures the application’s resources, dependencies, and configuration in a structured JSON format. That manifest becomes the basis for deploying to Azure Container Apps, where Azure Developer CLI can initialize the project, log in, provision infrastructure, and deploy the app. The chapter also shows how the same deployment flow can be driven from Visual Studio, how generated infrastructure files can be customized, and how the manifest can be translated into Terraform for broader cloud support.
Finally, the chapter extends the deployment story to Kubernetes by using tools that convert the Aspire manifest into Kubernetes-friendly YAML and then applying it to a cluster with kubectl. It closes by emphasizing CI/CD automation, demonstrating how to scaffold pipelines in GitHub Actions and Azure DevOps, add build and test stages before deployment, and adapt the scripts for Kubernetes-based releases. The overall message is that Aspire apps can be prepared once, then deployed and automated across multiple environments with a consistent, repeatable process.
Hosting multiple services in Aspire
Looking at the internal HTTP ports of individual instances
Accessing a custom command from the .NET Aspire dashboard
Publishing Aspire apps from Visual Studio
Selecting Azure Container App as a deployment target
Summary
- .NET Aspire has the ability to scale individual services out by running multiple instances of them.
- You can have separate logic for the local .NET Aspire instance and the deployed application.
- The .NET Aspire dashboard can be extended with additional custom commands.
- When hosting multiple instances of a service in Aspire, the load balancing is handled automatically.
- .NET Aspire can be integrated with a variety of other tools to be deployed on various cloud environments, such as the Azure Developer CLI.
- JSON files known as .NET Aspire manifests provide descriptions of all individual services hosted by Aspire.
- Aspire can be deployed in Azure Container Apps via the Azure Developer CLI.
- If we want to deploy it to a Kubernetes cluster in a cloud-agnostic fashion, we can convert Aspire manifests into YAML files that Kubernetes can understand by using a tool called Aspire8.
Building Distributed Applications that Work ebook for free