Перейти к содержимому

Create your first app

Это содержимое пока не доступно на вашем языке.

Aspire provides templates and tooling to quickly create and configure cloud-native apps in Visual Studio, VS Code, or the CLI. Prefer not to install anything locally? Start your first app in a Dev Container:

Открыть dotnet/aspire-devcontainer в GitHub Codespaces

Alternatively, assuming you have the prerequisites and Aspire CLI installed, you can create a new Aspire solution.

  1. Create a new Aspire solution:

    Create a new aspire solution
    aspire new aspire-starter -n AspireApp -o AspireApp

    If prompted for additional selections, use the Up Arrow Up Arrow Up Arrow and Down Arrow Down Arrow Down Arrow keys to navigate the options. Press Return Enter Enter to confirm your selection.

    For further CLI reference, see aspire new command information.

  2. Verify the solution was created successfully. The Aspire CLI creates a new folder named AspireApp in the current directory. This folder contains the solution file and several projects, including:

    • AspireApp.sln
    • ДиректорияAspireApp.ApiService
      • ДиректорияProperties/
      • appsettings.Development.json
      • appsettings.json
      • AspireApp.ApiService.csproj
      • Program.cs
    • ДиректорияAspireApp.AppHost this is your local dev-time orchestrator
      • ДиректорияProperties/
      • appsettings.Development.json
      • appsettings.json
      • AspireApp.AppHost.csproj
      • AppHost.cs
    • ДиректорияAspireApp.ServiceDefaults
      • Extensions.cs
      • AspireApp.ServiceDefaults.csproj
    • ДиректорияAspireApp.Web
      • ДиректорияProperties/
      • Директорияwwwroot/
      • appsettings.Development.json
      • appsettings.json
      • AspireApp.Web.csproj
      • Program.cs
      • WeatherApiClient.cs

    This solution structure is based on the Aspire templates. If they’re not installed already, the CLI will install them for you.

  3. Change to the output directory:

    Change directories—stepping into the output directory
    cd ./AspireApp
  4. Run the Aspire AppHost project:

    Run dev-time orchestration
    aspire run

    When you run this command, the Aspire CLI automatically finds the AppHost project, builds your solution, and launches dev-time orchestration. Once the dashboard is ready, its URL (with a login token) appears in your console. You’ll also see a live, real-time view of your running resources and their current states.

    Example output of aspire run
    Dashboard: https://localhost:17244/login?t=9db79f2885dae24ee06c6ef10290b8b2
    Logs: /home/vscode/.aspire/cli/logs/apphost-5932-2025-08-25-18-37-31.log
    Press CTRL+C to stop the apphost and exit.

    For further CLI reference, see aspire run command information.

  5. Explore the running distributed application. From the dashboard, open the HTTPS endpoint from each resource.

    Aspire dashboard Resources page displaying two running resources: apiservice and webfrontend. Both are marked as Running with green check icons. The table lists columns for Name, State, Start time, Source, URLs, and Actions. apiservice uses AspireApp.ApiService.csproj and has URLs https://localhost:7393 and webfrontend uses AspireApp.Web.csproj with URL https://localhost:7214. The interface has a dark theme with navigation options for Resources, Console, Structured, Traces, and Metrics on the left.

  6. Stop the AppHost and close the dashboard by pressing ⌘+C Control + C Control + C .

    🥳 Congratulations! You’ve created your first Aspire app.

Next, deepen your understanding of Aspire by learning how the AppHost defines your application’s architecture, and how deployment and app topology are defined once and reused across environments.

Последнее обновление:

Вопросы & ответы Сотрудничать Сообщество Обсуждать Смотреть