Deploy your first app — C# AppHost

In this tutorial, you take the app you created in the Build your first Aspire app — C# AppHost quickstart and deploy it. This can be broken down into several key steps:

  1. 1

    Add deployment package — Add the hosting package for your target.

  2. 2

    Update your AppHost — Configure the environment API.

  3. 3

    Deploy your app — Deploy using the Aspire CLI.

  4. 4

    Verify your deployment — Ensure your app is running as expected.

  5. 5

    Clean up resources — Remove any deployed resources to avoid incurring costs.

The following diagram shows the architecture of the sample app you're deploying:

Prerequisites

Depending on where you want to deploy your Aspire app, ensure you have the following prerequisites installed and configured:

Docker Compose

Azure

  • An Azure account with an active subscription.
  • Azure CLI installed and configured. You should be logged in using az login.

Add deployment package

In the root directory of your Aspire solution that you created in the previous quickstart, add the appropriate hosting deployment package by running the following command in your terminal:

Docker Compose

Azure

In the AppHost, chain a call to the appropriate environment API method to configure the deployment environment for your target.

Docker Compose

Azure

[!TIP] CLI protip After installing a new deployment package, you can run aspire do diagnostics in your terminal to see the available deploy steps. For more information, see the aspire do diagnostics reference docs.

Deploy your app

Now that you've added the deployment package and updated your AppHost, you can deploy your Aspire app.

Docker Compose

Azure

[!NOTE] Common pitfall... If you call aspire deploy and you see output similar to the following, be sure that you've actually updated your AppHost to include the appropriate environment API for your target. This output indicates that there are no deploy steps configured for your target environment.

14:17:26 (pipeline execution) → Starting pipeline execution...
14:17:26 (deploy) → Starting deploy...
14:17:26 (deploy) ✓ deploy completed successfully
14:17:26 (pipeline execution) ✓ Completed successfully
------------------------------------------------------------
 2/2 steps succeeded • Total time: 0.0s
  
Steps Summary:
0.0 s  ✓ pipeline execution
0.0 s  ✓ deploy
  
 PIPELINE SUCCEEDED
------------------------------------------------------------

Post deployment output

After a deployment, the Aspire CLI writes to the provided output path (or the default output path if none is provided) a set of files based on your deployment target. This may include files such as Docker Compose files, Kubernetes manifests, or cloud provider-specific configuration files.

Docker Compose

Azure

The deployment state is saved in a directory named after the SHA256 hash of your full AppHost path. This ensures that deployments for different applications or versions are kept separate.

Verify your deployment

To verify that your application is running as expected after deployment, follow the instructions for your chosen deployment target below.

Docker Compose

After deploying your application, it's important to clean up resources to avoid incurring unnecessary costs or consuming local system resources.

Docker Compose To clean up resources after deploying with Docker Compose, you can stop and remove the running containers using the following command:

Azure To clean up resources after deploying to Azure, you can use the Azure CLI to delete the resource group that contains your application. This will remove all resources within the resource group.

You've just built your first Aspire app and deployed it to production—congratulations! 🎉 Now you might be wondering: "How do I make sure all these services actually work together correctly?" That's where integration testing comes in. Aspire makes it easy to test your entire application stack, including service-to-service communication and resource dependencies. Ready to learn how? Write your first test