Skip to content

Commit 70d2439

Browse files
CopilotIEvangelist
andcommitted
Update Python template docs to use Aspire CLI and correct template structure
Co-authored-by: IEvangelist <[email protected]>
1 parent b79c5b3 commit 70d2439

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

docs/fundamentals/aspire-sdk-templates.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ The following Aspire solution templates are available, assume the solution is na
3939

4040
<a name="python-app"></a>
4141

42-
- **Aspire Python App**: A full-stack Aspire application with a Python backend and JavaScript frontend. This template includes:
42+
- **Aspire Python App**: A full-stack Aspire application with a Python backend and JavaScript frontend. This template uses a file-based AppHost and includes:
4343

44-
- [**AspireSample.AppHost**](#app-host): An orchestrator project to connect and configure services.
45-
- [**AspireSample.ServiceDefaults**](#service-defaults): A shared project for common configurations.
46-
- **AspireSample.Backend**: A Python backend using FastAPI framework with OpenTelemetry instrumentation.
47-
- **AspireSample.Frontend**: A JavaScript frontend using React framework.
44+
- **apphost.cs**: A file-based AppHost that orchestrates the Python backend and JavaScript frontend.
45+
- **app**: A Python backend using [FastAPI](https://fastapi.tiangolo.com/) framework with OpenTelemetry instrumentation.
46+
- **frontend**: A JavaScript frontend using [React](https://react.dev/) framework with Vite.
4847

4948
> [!NOTE]
5049
> The Aspire Python template is currently under development. For more information and updates, see [GitHub: Aspire issue #11865](https://github.com/dotnet/aspire/issues/11865). For now, you can manually add Python applications to an existing Aspire solution using the guidance in [Orchestrate Python apps in Aspire](../get-started/build-aspire-apps-with-python.md).
@@ -108,30 +107,30 @@ To create an Aspire solution or project using the .NET CLI, use the [dotnet new]
108107

109108
To create a basic [Aspire AppHost](app-host-overview.md) project targeting the latest .NET version:
110109

111-
```dotnetcli
112-
dotnet new aspire-apphost
110+
```Aspire
111+
aspire new aspire-apphost
113112
```
114113

115114
To create an Aspire starter app, which is a full solution with a sample UI and backing API included:
116115

117-
```dotnetcli
118-
dotnet new aspire-starter
116+
```Aspire
117+
aspire new aspire-starter
119118
```
120119

121120
To create an Aspire app with a Python backend and JavaScript frontend:
122121

123-
```dotnetcli
124-
dotnet new aspire-python
122+
```Aspire
123+
aspire new aspire-py-starter
125124
```
126125

127126
> [!NOTE]
128-
> The `aspire-python` template is currently under development. For more information, see [Build an Aspire app with Python and JavaScript](../get-started/build-aspire-python-app.md).
127+
> The `aspire-py-starter` template is currently under development. For more information, see [Build an Aspire app with Python and JavaScript](../get-started/build-aspire-python-app.md).
129128
130129
> [!TIP]
131130
> Aspire templates default to using the latest .NET version, even when using an earlier version of the .NET CLI. To manually specify the .NET version, use the `--framework <tfm>` option, for example to create a basic [Aspire AppHost](app-host-overview.md) project targeting .NET 8:
132131
>
133-
> ```dotnetcli
134-
> dotnet new aspire-apphost --framework net8.0
132+
> ```Aspire
133+
> aspire new aspire-apphost --framework net8.0
135134
> ```
136135
137136
You need to trust the ASP.NET Core :::no-loc text="localhost"::: certificate before running the app. Run the following command:

docs/get-started/build-aspire-python-app.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ai-usage: ai-assisted
88

99
# Build an Aspire app with Python and JavaScript
1010

11-
In this article, you learn how to create a new Aspire application using the Aspire Python template. The template creates a solution with a Python backend (using FastAPI) and a JavaScript frontend (using React), orchestrated by Aspire. This approach is ideal for Python developers who want to build observable, production-ready applications with modern JavaScript frontends.
11+
In this article, you learn how to create a new Aspire application using the Aspire Python template. The template creates a solution with a Python backend (using [FastAPI](https://fastapi.tiangolo.com/)) and a JavaScript frontend (using [React](https://react.dev/)), orchestrated by Aspire. This approach is ideal for Python developers who want to build observable, production-ready applications with modern JavaScript frontends.
1212

1313
> [!NOTE]
1414
> The Aspire Python template is currently under development. This documentation will be updated as the template becomes available. For now, you can follow the guidance in [Orchestrate Python apps in Aspire](build-aspire-apps-with-python.md) to manually add Python applications to an existing Aspire solution.
@@ -45,20 +45,19 @@ To download Node.js (including `npm`), see the [Node.js download page](https://n
4545
## Create an Aspire project using the Python template
4646

4747
> [!IMPORTANT]
48-
> The `aspire-python` template is currently being developed and might not be available yet. Once released, you'll be able to create a Python-based Aspire application using the following command. For updates on template availability, see [Aspire Python Templates (issue #11865)](https://github.com/dotnet/aspire/issues/11865).
48+
> The `aspire-py-starter` template is currently being developed and might not be available yet. Once released, you'll be able to create a Python-based Aspire application using the following command. For updates on template availability, see [Aspire Python Templates (issue #11865)](https://github.com/dotnet/aspire/issues/11865).
4949
50-
To create a new Aspire application with a Python backend and JavaScript frontend, use the `aspire-python` template:
50+
To create a new Aspire application with a Python backend and JavaScript frontend, use the `aspire-py-starter` template:
5151

52-
```dotnetcli
53-
dotnet new aspire-python -o MyPythonApp
52+
```Aspire
53+
aspire new aspire-py-starter
5454
```
5555

5656
This command creates a new Aspire solution with the following structure:
5757

58-
- **MyPythonApp.AppHost**: An orchestrator project designed to connect and configure the different projects and services of your app.
59-
- **MyPythonApp.ServiceDefaults**: A shared project to manage configurations that are reused across the projects in your solution related to resilience, service discovery, and telemetry.
60-
- **MyPythonApp.Backend**: A Python backend using FastAPI framework.
61-
- **MyPythonApp.Frontend**: A JavaScript frontend using React framework.
58+
- **apphost.cs**: A file-based AppHost that orchestrates the Python backend and JavaScript frontend.
59+
- **app**: A Python backend using [FastAPI](https://fastapi.tiangolo.com/) framework.
60+
- **frontend**: A JavaScript frontend using [React](https://react.dev/) framework with Vite.
6261

6362
## Explore the project structure
6463

@@ -68,33 +67,37 @@ Navigate to the newly created project directory:
6867
cd MyPythonApp
6968
```
7069

71-
### Python backend
70+
### File-based AppHost
7271

73-
The Python backend is located in the _MyPythonApp.Backend_ directory. It uses the FastAPI framework to create RESTful APIs. The backend includes:
72+
The solution uses a file-based AppHost with a single _apphost.cs_ file. This file contains the orchestration logic for both the Python backend and JavaScript frontend. The AppHost uses `AddPythonScript` to add the Python backend and `AddViteApp` to add the React frontend.
7473

75-
- A virtual environment for Python dependencies
76-
- A _requirements.txt_ file listing required Python packages
77-
- A _main.py_ file containing the FastAPI application code
78-
- OpenTelemetry instrumentation for observability
74+
### File-based AppHost
7975

80-
### JavaScript frontend
76+
The solution uses a file-based AppHost with a single _apphost.cs_ file. This file contains the orchestration logic for both the Python backend and JavaScript frontend. The AppHost uses `AddPythonScript` to add the Python backend and `AddViteApp` to add the React frontend.
77+
78+
### Python backend
79+
80+
The Python backend is located in the _app_ directory. It uses the [FastAPI](https://fastapi.tiangolo.com/) framework to create RESTful APIs. The backend includes:
8181

82-
The JavaScript frontend is located in the _MyPythonApp.Frontend_ directory. It uses React to create the user interface. The frontend includes:
82+
- A virtual environment for Python dependencies.
83+
- A _requirements.txt_ file listing required Python packages.
84+
- An _app.py_ file containing the FastAPI application code.
85+
- OpenTelemetry instrumentation for observability.
8386

84-
- A _package.json_ file listing required npm packages
85-
- Source code in the _src_ directory
86-
- Configuration for connecting to the backend API
87+
### JavaScript frontend
8788

88-
### AppHost orchestration
89+
The JavaScript frontend is located in the _frontend_ directory. It uses [React](https://react.dev/) with Vite to create the user interface. The frontend includes:
8990

90-
The AppHost project (_MyPythonApp.AppHost_) orchestrates both the Python backend and JavaScript frontend. It uses the `AddPythonApp` and `AddNpmApp` APIs to configure and run these applications together.
91+
- A _package.json_ file listing required npm packages.
92+
- Source code in the _src_ directory.
93+
- Configuration for connecting to the backend API.
9194

9295
## Set up the Python environment
9396

9497
Navigate to the Python backend directory:
9598

9699
```console
97-
cd MyPythonApp.Backend
100+
cd app
98101
```
99102

100103
Create and activate a Python virtual environment:
@@ -127,7 +130,7 @@ python -m pip install -r requirements.txt
127130
Navigate to the JavaScript frontend directory:
128131

129132
```console
130-
cd ../MyPythonApp.Frontend
133+
cd ../frontend
131134
```
132135

133136
Install the npm dependencies:
@@ -144,10 +147,10 @@ Navigate back to the solution root directory:
144147
cd ..
145148
```
146149

147-
Run the AppHost project to start the application:
150+
Run the AppHost to start the application:
148151

149-
```dotnetcli
150-
dotnet run --project MyPythonApp.AppHost/MyPythonApp.AppHost.csproj
152+
```Aspire
153+
aspire run
151154
```
152155

153156
The Aspire dashboard opens in your browser. You should see both the Python backend and JavaScript frontend listed as resources.
@@ -156,34 +159,34 @@ The Aspire dashboard opens in your browser. You should see both the Python backe
156159

157160
The Aspire dashboard provides a unified view of your application's resources, including:
158161

159-
- **Resources**: View all running services (Python backend and JavaScript frontend)
160-
- **Logs**: See consolidated logs from all services
161-
- **Traces**: Monitor distributed traces across your application
162-
- **Metrics**: View performance metrics and telemetry data
162+
- **Resources**: View all running services (Python backend and JavaScript frontend).
163+
- **Logs**: See consolidated logs from all services.
164+
- **Traces**: Monitor distributed traces across your application.
165+
- **Metrics**: View performance metrics and telemetry data.
163166

164167
Select the **Endpoints** link for each resource to access:
165168

166-
- The React frontend user interface
167-
- The FastAPI backend API documentation (Swagger UI)
169+
- The React frontend user interface.
170+
- The FastAPI backend API documentation (Swagger UI).
168171

169172
## Understand telemetry and observability
170173

171174
The Python backend and JavaScript frontend are both configured with OpenTelemetry for observability. This means:
172175

173-
- **Logs** from both applications are collected and displayed in the Aspire dashboard
174-
- **Traces** show the flow of requests across services
175-
- **Metrics** provide insights into application performance
176+
- **Logs** from both applications are collected and displayed in the Aspire dashboard.
177+
- **Traces** show the flow of requests across services.
178+
- **Metrics** provide insights into application performance.
176179

177180
The template includes OpenTelemetry packages configured to export telemetry data to the Aspire dashboard automatically.
178181

179182
## Next steps
180183

181184
Now that you have a working Aspire application with Python and JavaScript:
182185

183-
- Explore the FastAPI backend code and add new API endpoints
184-
- Customize the React frontend to create your user interface
185-
- Add additional services or resources to your AppHost
186-
- Deploy your application to a cloud environment
186+
- Explore the FastAPI backend code and add new API endpoints.
187+
- Customize the React frontend to create your user interface.
188+
- Add additional services or resources to your AppHost.
189+
- Deploy your application to a cloud environment.
187190

188191
## See also
189192

0 commit comments

Comments
 (0)