Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6ce6621
Update docs/serverless/functions.md
captainsafia Feb 6, 2025
8525592
Update Azure Service Bus integration doc (#2365)
IEvangelist Feb 11, 2025
9bb6693
Resource notifications (#2568)
IEvangelist Feb 11, 2025
b1f8341
Fixes breaking changes doc issues (#2619)
IEvangelist Feb 13, 2025
30827c1
Shell for what's new content (#2620)
IEvangelist Feb 13, 2025
d95d35c
Fixes #1659 (#2621)
IEvangelist Feb 14, 2025
62bb392
Rewritten Azure Event Hubs integration content (#2562)
IEvangelist Feb 14, 2025
5d4d702
Upgrade bits to 9.1 (#2627)
IEvangelist Feb 14, 2025
41cede0
[9.1] Force waiting resource to start (#2629)
JamesNK Feb 18, 2025
638ef54
[9.1] Add WithExplicitStart (#2630)
JamesNK Feb 18, 2025
9ff056e
Add DOTNET_DASHBOARD_CORS_ALLOWED_ORIGINS to app host configuration (…
JamesNK Feb 18, 2025
fe61b99
Fix invalid file link warning (#2635)
IEvangelist Feb 18, 2025
2491e8a
Codespaces docs.
mitchdenny Feb 19, 2025
f566ce1
Remove pivot.
mitchdenny Feb 19, 2025
b65b3b3
Pivot removal.
mitchdenny Feb 19, 2025
dbafa71
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
d0e9060
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
6e757e7
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
1ab1bfc
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
ceddad5
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
810e9f3
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
b94bc82
Update docs/fundamentals/codespaces.md
mitchdenny Feb 20, 2025
efb1a8e
Update docs/fundamentals/devcontainers.md
mitchdenny Feb 20, 2025
c22c001
Update docs/fundamentals/devcontainers.md
mitchdenny Feb 20, 2025
0de4180
Update docs/fundamentals/devcontainers.md
mitchdenny Feb 20, 2025
7eec700
Merge branch 'dotnet-aspire-9.1' into dotnet-aspire-9.1-codespaces
mitchdenny Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions docs/fundamentals/codespaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does codespaces belong under "fundamentals"? That doesn't seem like an appropriate place for it.

image

The other things are fundamental to Aspire.

Maybe these docs could be under "Get Started" => "Setup and tooling"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. That makes more sense. Should probably be nested as follows:

  • Get started
    • Setup and Tooling
      • Overview
      • .NET Aspire SDK
      • .NET Aspire Templates
      • GitHub Codespaces
      • Devcontainers

title: .NET Aspire and GitHub Codespaces
description: Learn how to use .NET Aspire with GitHub Codespaces.
ms.date: 02/19/2025
---

# .NET Aspire and GitHub Codespaces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to this document from the 9.1 "What's new" doc?


[GitHub Codespaces](https://github.com/features/codespaces) offers a cloud-hosted development environment based on Visual Studio Code. It can be accessed directly from a web browser or through Visual Studio Code locally, where Visual Studio Code acts as a client connecting to a cloud-hosted backend. With .NET Aspire 9.1, comes logic to better support GitHub Codespaces including:

- Automatically configure port forwarding with the correct protocol.
- Automatically translate URLs in the .NET Aspire dashboard.

Prior to .NET Aspire 9.1 it was still possible to use .NET Aspire within a GitHub Codespace, however more manual configuration was required.

## GitHub Codespaces vs. Devcontainers

GitHub Codespaces builds upon Visual Studio Code and the [Devcontainers specification](https://containers.dev/implementors/spec/). In addition to supporting GitHub Codespaces, .NET Aspire 9.1 enhances support for using Visual Studio Code and locally hosted Devcontainers. While the experiences are similar, there are some differences. For more information, see [.NET Aspire with Devcontainers in Visual Studio Code](devcontainers.md).

## Quick start using template repository

To configure GitHub Codespaces for .NET Aspire, use the _.devcontainer/devcontainer.json_ file in your repository. The simplest way to get started is by creating a new repository from our [template repository](https://github.com/dotnet/aspire-devcontainer). Consider the following steps:

1. [Create a new repository](https://github.com/new?template_name=aspire-devcontainer&template_owner=dotnet) using our template.

![Create new repository](media/new-repository-from-template.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Create new repository](media/new-repository-from-template.png)
:::image source="media/new-repository-from-template.png" lightbox="media/new-repository-from-template.png" alt-text="Create new repository.":::


Once you provide the details and click _Create repository_ the repository will be created and you will be shown the repository in GitHub.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Once you provide the details and click _Create repository_ the repository will be created and you will be shown the repository in GitHub.
Once you provide the details and select **Create repository**, the repository is created and shown in GitHub.


1. From the new repository click on the Code button and select the Codespaces tab and then select **Create codespace on main**.

![Create codespace](media/create-codespace-from-repository.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Create codespace](media/create-codespace-from-repository.png)
:::image source="media/create-codespace-from-repository.png" lightbox="media/create-codespace-from-repository.png" alt-text="Create codespace":::


Once you click on this button you will be navigate to a web-based version of Visual Studio Code. Before using the Codespace the containerized development environment needs to be prepared. This process happens automatically on the server and you can review progress by clicking on the _Building codespace_ link in the notification in the bottom right of the browser window.

![Building codespace](media/building-codespace-image.png)

Once the container image has finished being built the _Terminal_ prompt appears which signals that the environment is ready to be interacted with.

![Codespace terminal prompt](media/codespace-terminal.png)

At this point the .NET Aspire templates have been pre-installed and the ASP.NET Core developer certificate has been pre-configured.
Comment on lines +34 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Once you click on this button you will be navigate to a web-based version of Visual Studio Code. Before using the Codespace the containerized development environment needs to be prepared. This process happens automatically on the server and you can review progress by clicking on the _Building codespace_ link in the notification in the bottom right of the browser window.
![Building codespace](media/building-codespace-image.png)
Once the container image has finished being built the _Terminal_ prompt appears which signals that the environment is ready to be interacted with.
![Codespace terminal prompt](media/codespace-terminal.png)
At this point the .NET Aspire templates have been pre-installed and the ASP.NET Core developer certificate has been pre-configured.
Once you select the **Create codespace on main** button, you navigate to a web-based version of Visual Studio Code. Before using the Codespace, the containerized development environment needs to be prepared. This process happens automatically on the server and you can review progress by selecting the **Building codespace** link on the notification in the bottom right of the browser window.
:::image source="media/building-codespace-image.png" lightbox="media/building-codespace-image.png" alt-text="Building codespace":::
Once the container image has finished being built the **Terminal** prompt appears which signals that the environment is ready to be interacted with.
:::image source="media/codespace-terminal.png" lightbox="media/codespace-terminal.png" alt-text="Codespace terminal prompt":::
At this point the .NET Aspire templates has been pre-installed and the ASP.NET Core developer certificate has been pre-configured.


3. Create a new .NET Aspire project using the starter template.

Check failure on line 44 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Ordered list item prefix

docs/fundamentals/codespaces.md:44:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 3; Style: 1/1/1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md029.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. Create a new .NET Aspire project using the starter template.
1. Create a new .NET Aspire project using the starter template.


```dotnetcli
dotnet new aspire-starter --name HelloAspire
```

This will result in a number of files and folders being created in the repository which will be visible in the _Explorer_ panel on the left hand side of the window.

![Codespaces Explorer panel](media/codespaces-explorer-panel.png)
Comment on lines +50 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot make a suggestion for the code block above this, but it should also be indented 4-spaces so that it renders as a child of this numbered list.

Suggested change
This will result in a number of files and folders being created in the repository which will be visible in the _Explorer_ panel on the left hand side of the window.
![Codespaces Explorer panel](media/codespaces-explorer-panel.png)
This results in a number of files and folders being created in the repository, which are visible in the **Explorer** panel on the left side of the window.
:::image source="media/codespaces-explorer-panel.png" lightbox="media/codespaces-explorer-panel.png" alt-text="Codespaces Explorer panel":::


4. Launch the app host via the `HelloAspire.AppHost/Program.cs` file.

Check failure on line 54 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Ordered list item prefix

docs/fundamentals/codespaces.md:54:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 4; Style: 1/1/1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md029.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Launch the app host via the `HelloAspire.AppHost/Program.cs` file.
1. Launch the app host via the _HelloAspire.AppHost/Program.cs_ file, by selecting the **Run project** button near the top-right corner of the **Tab bar**.


![Launch AppHost in Codespace](media/codespace-launch-apphost.png)

After a few moments the _Debug Console_ panel will become visible and it will show a link to the .NET Aspire dashboard exposed on a GitHub Codespaces endpoint with the authentication token.

![Codespaces debug console](media/codespaces-debug-console.png)
Comment on lines +56 to +60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Launch AppHost in Codespace](media/codespace-launch-apphost.png)
After a few moments the _Debug Console_ panel will become visible and it will show a link to the .NET Aspire dashboard exposed on a GitHub Codespaces endpoint with the authentication token.
![Codespaces debug console](media/codespaces-debug-console.png)
:::image source="media/codespace-launch-apphost.png" lightbox="media/codespace-launch-apphost.png" alt-text="Launch app host in Codespace":::
After a few moments the **Debug Console** panel is displayed, and it includes a link to the .NET Aspire dashboard exposed on a GitHub Codespaces endpoint with the authentication token.
:::image source="media/codespaces-debug-console.png" lightbox="media/codespaces-debug-console.png" alt-text="Codespaces debug console":::


5. Open the .NET Aspire dashboard by clicking on the dashboard URL in the debug console. This will cause the .NET Aspire dashboard to be opened in a separate tab within your browser.

Check failure on line 62 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Ordered list item prefix

docs/fundamentals/codespaces.md:62:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 5; Style: 1/1/1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md029.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
5. Open the .NET Aspire dashboard by clicking on the dashboard URL in the debug console. This will cause the .NET Aspire dashboard to be opened in a separate tab within your browser.
1. Open the .NET Aspire dashboard by selecting the dashboard URL in the **Debug Console**. This opens the .NET Aspire dashboard in a separate tab within your browser.


Notice in the dashboard that all HTTP/HTTPS endpoints defined on resources have had their typical `localhost` address translated to a unique fully qualified domain on the `app.github.dev` domain.

![Codespaces translated URLs](media/codespaces-translated-urls.png)

Traffic to each of these endpoints will be automatically forwarded to the underlying process or container running within the Codespace. This includes development time tools such as as PGAdmin and Redis Insight.

> NOTE: In addition to the authentication token embedded within the URL of the dashboard link of the _Debug Console_, endpoints also require authentication via your GitHub identity to avoid port forwarded endpoints being accessible to everyone. For more information on port forwarding in GitHub Codespaces see [Forwarding ports in your codespace](https://docs.github.com/en/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace?tool=webui).
Comment on lines +64 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Notice in the dashboard that all HTTP/HTTPS endpoints defined on resources have had their typical `localhost` address translated to a unique fully qualified domain on the `app.github.dev` domain.
![Codespaces translated URLs](media/codespaces-translated-urls.png)
Traffic to each of these endpoints will be automatically forwarded to the underlying process or container running within the Codespace. This includes development time tools such as as PGAdmin and Redis Insight.
> NOTE: In addition to the authentication token embedded within the URL of the dashboard link of the _Debug Console_, endpoints also require authentication via your GitHub identity to avoid port forwarded endpoints being accessible to everyone. For more information on port forwarding in GitHub Codespaces see [Forwarding ports in your codespace](https://docs.github.com/en/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace?tool=webui).
You'll notice on the dashboard that all HTTP/HTTPS endpoints defined on resources have had their typical `localhost` address translated to a unique fully qualified subdomain on the `app.github.dev` domain.
:::image source="media/codespaces-translated-urls.png" lightbox="media/codespaces-translated-urls.png" alt-text="Codespaces translated URLs":::
Traffic to each of these endpoints is automatically forwarded to the underlying process or container running within the Codespace. This includes development time tools such as PgAdmin and Redis Insight.
> [!NOTE]
> In addition to the authentication token embedded within the URL of the dashboard link of the **Debug Console**, endpoints also require authentication via your GitHub identity to avoid port forwarded endpoints being accessible to everyone. For more information on port forwarding in GitHub Codespaces see [Forwarding ports in your codespace](https://docs.github.com/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace?tool=webui).


6. Commit changes to the GitHub repository.

Check failure on line 72 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Ordered list item prefix

docs/fundamentals/codespaces.md:72:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 6; Style: 1/1/1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md029.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
6. Commit changes to the GitHub repository.
1. Commit changes to the GitHub repository.


GitHub Codespaces does not automatically commit changes you make in the Codespace to the branch you are working on in GitHub. Use the Source Control panel to stage and commit the changes and push them back to the repository.

Working in a GitHub Codespace is very similar to working with Visual Studio Code on your own PC. You can checkout different branches and push changes just like you normally would. In addition you can easily spin up multiple Codespaces simultaneously if you want to quickly work on another branch without disrumpting your existing debug session. See [Developing in a codespace](https://docs.github.com/en/codespaces/developing-in-a-codespace/developing-in-a-codespace?tool=webui) for more information.
Comment on lines +74 to +76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GitHub Codespaces does not automatically commit changes you make in the Codespace to the branch you are working on in GitHub. Use the Source Control panel to stage and commit the changes and push them back to the repository.
Working in a GitHub Codespace is very similar to working with Visual Studio Code on your own PC. You can checkout different branches and push changes just like you normally would. In addition you can easily spin up multiple Codespaces simultaneously if you want to quickly work on another branch without disrumpting your existing debug session. See [Developing in a codespace](https://docs.github.com/en/codespaces/developing-in-a-codespace/developing-in-a-codespace?tool=webui) for more information.
GitHub Codespaces doesn't automatically commit your changes to the branch you're working on in GitHub. You have to use the **Source Control** panel to stage and commit the changes and push them back to the repository.
Working in a GitHub Codespace is very similar to working with Visual Studio Code on your own machine. You can checkout different branches and push changes just like you normally would. In addition, you can easily spin up multiple Codespaces simultaneously if you want to quickly work on another branch without disrupting your existing debug session. For more information, see [Developing in a codespace](https://docs.github.com/codespaces/developing-in-a-codespace/developing-in-a-codespace?tool=webui).


7. Cleaning up your codespace

Check failure on line 78 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Ordered list item prefix

docs/fundamentals/codespaces.md:78:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 7; Style: 1/1/1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md029.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
7. Cleaning up your codespace
1. Clean up your Codespace.


GitHub Codespaces are temporary development environments and whilst you might use one for an extended period of time they should be considered a disposable resource that you recreate when you need it (with all of the customization/setup contained within `devcontainer.json` and associated configuration files).

To delete your GitHub Codespace visit the GitHub Codespaces page. This will show you a list of all of your codespaces. From here you can perform management operations on each Codespace including deleting them.

GitHub charges for the use of Codespaces. For more information see [Managing the cost of GitHub Codespaces in your organization](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/choosing-who-owns-and-pays-for-codespaces-in-your-organization).

> NOTE: .NET Aspire supports the use of Devcontainers in Visual Studio Code indepent of GitHub Codespaces. For more information on how to use Devcontainers locally see [.NET Aspire and Devcontainers in Visual Studio Code](devcontainers.md).
Comment on lines +80 to +86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GitHub Codespaces are temporary development environments and whilst you might use one for an extended period of time they should be considered a disposable resource that you recreate when you need it (with all of the customization/setup contained within `devcontainer.json` and associated configuration files).
To delete your GitHub Codespace visit the GitHub Codespaces page. This will show you a list of all of your codespaces. From here you can perform management operations on each Codespace including deleting them.
GitHub charges for the use of Codespaces. For more information see [Managing the cost of GitHub Codespaces in your organization](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/choosing-who-owns-and-pays-for-codespaces-in-your-organization).
> NOTE: .NET Aspire supports the use of Devcontainers in Visual Studio Code indepent of GitHub Codespaces. For more information on how to use Devcontainers locally see [.NET Aspire and Devcontainers in Visual Studio Code](devcontainers.md).
GitHub Codespaces are temporary development environments and whilst you might use one for an extended period of time, they should be considered a disposable resource that you recreate as needed (with all of the customization/setup contained within the _devcontainer.json_ and associated configuration files).
To delete your GitHub Codespace visit the GitHub Codespaces page. This shows you a list of all of your Codespaces. From here you can perform management operations on each Codespace, including deleting them.
GitHub charges for the use of Codespaces. For more information, see [Managing the cost of GitHub Codespaces in your organization](https://docs.github.com/codespaces/managing-codespaces-for-your-organization/choosing-who-owns-and-pays-for-codespaces-in-your-organization).
> [!NOTE]
> .NET Aspire supports the use of Devcontainers in Visual Studio Code independent of GitHub Codespaces. For more information on how to use Devcontainers locally, see [.NET Aspire and Devcontainers in Visual Studio Code](devcontainers.md).


## Manually configuring `devcontainer.json`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Manually configuring `devcontainer.json`
## Manually configuring _devcontainer.json_


The above walkthrough shows the streamlined process of creating a GitHub Codespace using the .NET Aspire Devcontainer template. If you already have a repository established and want to start using Devcontainer functionality in .NET Aspire with that then you just need to add a `devcontainer.json` file to the `.devcontainer` folder within your repository.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The above walkthrough shows the streamlined process of creating a GitHub Codespace using the .NET Aspire Devcontainer template. If you already have a repository established and want to start using Devcontainer functionality in .NET Aspire with that then you just need to add a `devcontainer.json` file to the `.devcontainer` folder within your repository.
The preceding walkthrough demonstrates the streamlined process of creating a GitHub Codespace using the .NET Aspire Devcontainer template. If you already have an existing repository and wish to utilize Devcontainer functionality with .NET Aspire, simply add a _devcontainer.json_ file to the _.devcontainer_ folder within your repository.


The template repository contains a copy of the `devcontainer.json` file that you can use as a starting point which should be sufficient for .NET Aspire. Here is a snapshot of that file for reference (be sure to check the [template repository](https://github.com/dotnet/aspire-devcontainer) for the latest version):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can point to the latest version, we just need to add the https://github.com/dotnet/aspire-devcontainer entry to this file:

https://github.com/dotnet/docs-aspire/blob/main/.openpublishing.publish.config.json

Specifically, the dependent_repositories node, add the following array entry after the aspire-samples:

    {
      "path_to_root": "aspire-devcontainer",
      "url": "https://github.com/dotnet/aspire-devcontainer",
      "branch": "main",
      "branch_mapping": {}
    },

This enables the docs to reference code in that repo, using the :::code ::: syntax.

Suggested change
The template repository contains a copy of the `devcontainer.json` file that you can use as a starting point which should be sufficient for .NET Aspire. Here is a snapshot of that file for reference (be sure to check the [template repository](https://github.com/dotnet/aspire-devcontainer) for the latest version):
The [template repository](https://github.com/dotnet/aspire-devcontainer) contains a copy of the _devcontainer.json_ file that you can use as a starting point, which should be sufficient for .NET Aspire. The following is the latest version of the _.devcontainer/devcontainer.json_ file from the template:


```json
{
"name": ".NET Aspire",

Check failure on line 96 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Hard tabs

docs/fundamentals/codespaces.md:96:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md010.md
"image": "mcr.microsoft.com/devcontainers/dotnet:dev-9.0-bookworm",

Check failure on line 97 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Hard tabs

docs/fundamentals/codespaces.md:97:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md010.md
"features": {

Check failure on line 98 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Hard tabs

docs/fundamentals/codespaces.md:98:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md010.md
"ghcr.io/devcontainers/features/azure-cli:1": {},

Check failure on line 99 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Hard tabs

docs/fundamentals/codespaces.md:99:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md010.md
"ghcr.io/devcontainers/features/docker-in-docker:2": {},

Check failure on line 100 in docs/fundamentals/codespaces.md

View workflow job for this annotation

GitHub Actions / lint

Hard tabs

docs/fundamentals/codespaces.md:100:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md010.md
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/azure/azure-dev/azd:0": {}
},

"hostRequirements": {
"cpus": 8,
"memory": "32gb",
"storage": "64gb"
},

"onCreateCommand": "dotnet new install Aspire.ProjectTemplates::9.1.0 --force",
"postStartCommand": "dotnet dev-certs https --trust",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"ms-azuretools.vscode-bicep",
"ms-azuretools.azure-dev",
"GitHub.copilot-chat",
"GitHub.copilot"
]
}
}
}
```
Comment on lines +94 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this entire JSON blob, and replace it with the following:

:::code language="json" source="~/aspire-devcontainer/.devcontainer/devcontainer.json":::


## Speed up Codespace creation

Creating a GitHub Codespace can take some time as it prepares the underlying container image. To expedite this process, you can utilize _pre-builds_ to significantly reduce the creation time to approximately 30-60 seconds (exact timing might vary). For more information on GitHub Codespaces pre-builds, see [GitHub Codespaces prebuilds](https://docs.github.com/codespaces/prebuilding-your-codespaces/about-github-codespaces-prebuilds).

15 changes: 15 additions & 0 deletions docs/fundamentals/devcontainers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Devcontainers in Visual Studio Code
description: Learn how to use .NET Aspire with Devcontainers in Visual Studio Code.
ms.date: 02/19/2025
---

# .NET Aspire and Visual Studio Code Devcontainers

The [Devcontainers Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) provides a way for development teams to develop within a containerized environment where all dependencies are preconfigured. With .NET Aspire 9.1, there's added logic to better support working with .NET Aspire within a Devcontainer environment by automatically configuring port forwarding.

Prior to .NET Aspire 9.1 it was still possible to use .NET Aspire within a Devcontainer, however more manual configuration was required.

## Devcontainers vs. GitHub Codespaces

Using Devcontainers in Visual Studio Code is quite similar to using GitHub Codespaces. With the release of .NET Aspire 9.1, support for both Devcontainers in Visual Studio Code and GitHub Codespaces has been enhanced. Although the experiences are similar, there are some differences. For more information on using .NET Aspire with GitHub Codespaces, see [.NET Aspire and GitHub Codespaces](codespaces.md).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/fundamentals/media/codespace-terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.