You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/dotnet-aspire/README.md
+93-33
Original file line number
Diff line number
Diff line change
@@ -12,89 +12,144 @@ A development environment for .NET Aspire and Azure SQL, enabling streamlined lo
12
12
13
13
This dev container template enables you to effortlessly explore **.NET Aspire** and **Azure SQL**. In just a few simple steps, you can dive into the capabilities of these powerful technologies.
14
14
15
-
A **development container** (Dev Container for short) is a running [Docker](https://www.docker.com) container with a well-defined tool/runtime stack and its prerequisites. You can try out dev containers with **[GitHub Codespaces](https://github.com/features/codespaces)** or **[Visual Studio Code Dev Containers](https://aka.ms/vscode-remote/containers)**.
15
+
A **development container** (dev container for short) essentially packages up your project's development environment using the Development Container Specification. This specification enriches your container with metadata and content necessary to enable development from inside a container.
16
16
17
-
To learn more details about all the Azure SQL Database templates, you can explore the template repository at [aka.ms/azuresql-devcontainers](https://aka.ms/azuresql-devcontainers). This repository includes comprehensive information for each Azure SQL template. To learn more about Dev Containers, visit [containers.dev](https://containers.dev/) website, where you find a diverse range of templates.
17
+
You can try out dev containers with **[GitHub Codespaces](https://github.com/features/codespaces)** or **[Visual Studio Code Dev Containers](https://aka.ms/vscode-remote/containers)**.
18
18
19
-
> **Note:**
20
-
> If you already have a Codespace or Dev Container, you can jump to the [About this template](#about-this-template) section.
19
+
To learn more details about all the Azure SQL Database templates, you can explore the template repository at [aka.ms/azuresql-devcontainers-repo](https://aka.ms/azuresql-devcontainers-repo). This repository includes comprehensive information for each Azure SQL template. To learn more about Dev Containers, visit [containers.dev](https://containers.dev/) website, where you find a diverse range of templates.
21
20
22
-
## Setting up the development container
23
-
24
-
### GitHub Codespaces
25
-
26
-
Follow these steps to open this sample in a Codespaces:
21
+
> [!NOTE]
22
+
> If you already have a VS Code Dev Container or a GitHub Codespace, you can jump to the [About this template](#about-this-template) section.
27
23
28
-
1. Select the Code drop-down menu and select the **Codespaces** tab.
29
-
2. Select on **Create codespaces on main** at the bottom of the pane.
30
-
31
-
For more info, check out the [GitHub documentation](https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces/creating-a-codespace#creating-a-codespace).
24
+
## Setting up the development container
32
25
33
-
### Visual Studio Code - Dev Containers
26
+
### Visual Studio Code
34
27
35
28
Follow these steps to open this sample in a container using the VS Code Dev Containers extension:
36
29
37
30
1. If you're using a dev container for the first time, ensure your system meets the prerequisites in the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started).
38
31
2. To use this repository, you can either open the repository in an isolated Docker volume:
39
32
- Press `F1` or `Ctrl+Shift+P` to open the command palette.
40
33
- Select the **Dev Containers: New Dev Container** command.
41
-
- Select the desired dev container template for Azure SQL Database, typing `*Azure SQL*`.
34
+
- Select the desired dev container template for Azure SQL Database, typing **Azure SQL**.
42
35
- Select the **.NET with Aspire and Azure SQL (dotnet-aspire)** template
43
36
- Wait for the container to build.
44
37
- Visual Studio Code builds the container based on the selected configuration.
45
38
- The build process might take a few minutes the first time.
46
39
- Subsequent builds are faster.
47
40
- Once the container is built, the repository opens in the dev container.
48
41
49
-
> **Note:**
42
+
For more information, see the [Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial).
43
+
44
+
> [!NOTE]
50
45
> Under the hood, this will use the **Dev Containers: Clone Repository in Container Volume...** command to clone the source code in a Docker volume instead of the local filesystem. [Volumes](https://docs.docker.com/storage/volumes/) are the preferred mechanism for persisting container data.
51
46
47
+
### GitHub Codespaces
48
+
49
+
To set up and use a dev container with GitHub Codespaces, follow these steps:
50
+
51
+
1.**Prerequisites**
52
+
- Ensure you have access to GitHub Codespaces.
53
+
- Ensure your repository is hosted on GitHub.
54
+
55
+
2.**Create or Open a Codespace**
56
+
- Navigate to your repository on GitHub.
57
+
- Click on the **Code** button, then select **Codespaces**.
58
+
- Click **New codespace** to create a new one or **...** next to an existing codespace to open it.
59
+
60
+
3.**Set Up the Development Container**
61
+
- Once your codespace is running, open the command palette by pressing `F1` or `Ctrl+Shift+P`.
62
+
- Type and select **Dev Containers: Add Development Container Configuration Files...**.
63
+
- From the list, select **Show All Definitions...**.
64
+
- Type **Azure SQL** to filter the list.
65
+
- Select the **.NET with Aspire and Azure SQL (dotnet-aspire)** template.
66
+
- The selected template will be added to your repository, creating a `.devcontainer` folder with configuration files.
67
+
68
+
4.**Rebuild the Codespace**
69
+
- To apply the new configuration, you need to rebuild the codespace.
70
+
- Open the command palette by pressing `F1` or `Ctrl+Shift+P` again.
71
+
- Type and select **Codespaces: Rebuild Container**.
72
+
- Wait for the container to rebuild. This might take a few minutes the first time as it pulls and sets up the necessary images and configurations.
73
+
74
+
5.**Using the Dev Container**
75
+
- Once the container is built, your codespace will restart in the new development environment.
76
+
- You can now start exploring and developing with the preconfigured .NET Aspire and Azure SQL setup.
77
+
78
+
> [!NOTE]
79
+
> The `.devcontainer` folder includes configuration files like `devcontainer.json`, `docker-compose.yml`, and supporting scripts for setting up and managing the development environment.
80
+
52
81
### About this template
53
82
54
-
This dev container includes a preconfigured database, tailored for use with the Aspire component. This database serves as a foundation for demonstrating how the Aspire component interacts with Azure SQL.
83
+
This Dev Container includes a preconfigured database, specifically tailored for use with .NET Aspire. This database serves as a foundation for demonstrating how .NET Aspire interacts with Azure SQL.
55
84
56
-
This template creates two containers, one for the dev container that includes .NET and Aspire, and one for Microsoft SQL Server. You're connected to the Ubuntu, and from within that container, the MS SQL container is available on **`localhost`** port 1433. The dev container also includes supporting scripts in the `.devcontainer/sql` folder used to configure the `Library` sample database.
85
+
This template creates two containers: one for container that includes .NET Aspire, and one for the database. You will be connected to the Ubuntu environment, and from within that container, the database container will be available on **`localhost`** port 1433. The dev container also includes a set of VS Code tasks that can help you to verify the database schema and data, as well as build and publish the database project to the database container.
57
86
58
-
The database container (SQL-Library) is deployed from the latest developer edition of Azure SQL Edge. The database(s) are made available directly in the Codespace/VS Code through the MSSQL extension with a connection labeled **LocalDev**. The default sa user password is set using the `.devcontainer/.env` file. The default SQL port is mapped to port 1433 in `.devcontainer/docker-compose.yml`.
87
+
The database container (SQL-Library) is deployed from the latest developer edition of Azure SQL Edge. The database(s) are made available directly in VS Code through the MSSQL extension with a connection labeled **LocalDev**. The default `sa` user password is set using the `.devcontainer/.env` file. The default SQL port is mapped to port `1433` in `.devcontainer/docker-compose.yml`.
59
88
60
89
.NET Aspire is a cutting-edge framework crafted for developing cloud-native applications, with a primary focus on containerized environments. Aspire, built with .NET Core, empowers developers to architect scalable and resilient applications optimized for cloud deployment.
61
90
62
-
> **Note:**
91
+
> [!IMPORTANT]
63
92
> While the database container employs a development version of Azure SQL Edge , all database development within this dev container can be validated for Azure SQL Database using the SQL Database Project. The SQL Database project is preconfigured with the target platform set as Azure SQL Database.
93
+
>
94
+
> To learn more about the SQL Database Projects extension, visit the [Getting started with the SQL Database Projects extension](/azure-data-studio/extensions/sql-database-project-extension-getting-started).
95
+
96
+
### Preconfigured Environment
97
+
98
+
All of the below tools and utilities are pre-loaded in the Dev Container. You don't need to download or install!
99
+
100
+
-**.NET** : The environment includes your preferred programming language/framework preinstalled and configured, ready for development.
101
+
-**Azure CLI**: Tools for managing Azure resources and deployments.
102
+
-**Azure Developer CLI**: A command-line interface providing a unified scripting experience for managing and developing Azure resources.
103
+
-**Docker CLI**: Allows building and managing Docker containers from within another container.
104
+
-**Azure SQL Database**: The `library` database was created, validated, and is ready for use. This database gives you full compatibility with Azure SQL Database.
105
+
-**SQLCMD**: A command-line utility you can use to interact with the database, run queries, and more.
106
+
-**SqlPackage**: Command-line utility for deploying database changes, including schema updates and data migrations.
107
+
108
+
### Visual Studio Code Extensions
109
+
110
+
-`ms-mssql.mssql`: SQL Server extension for connecting and querying SQL databases.
111
+
-`ms-mssql.sql-database-projects`: Extension for managing SQL Database projects, allowing for streamlined schema changes and deployment.
112
+
-`github.copilot`: AI-powered code completion for enhanced productivity.
113
+
-`ms-azuretools.vscode-docker`: Docker extension for managing containers directly from Visual Studio Code.
114
+
-`github.codespaces`: Extension for working with GitHub Codespaces.
115
+
-`ms-azuretools.vscode-docker`: Docker extension for managing containers.
116
+
117
+
> [!TIP]
118
+
> There will be more extensions available depending on the template you choose. You can install additional extensions by opening the Extensions view in Visual Studio Code and searching for the desired extension.
64
119
65
120
#### Visual Code Tasks
66
121
67
122
This dev container template includes multiple tasks that can help with common actions. You can access these tasks by opening the Command Palette in VS Code. Here's how:
68
123
69
124
1. To open the Command Palette, press <kbd>F1</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>.
70
-
2. Type "Run Task" and select "Tasks: Run Task".
125
+
2. Type **Run Task** and select **Tasks: Run Task**.
71
126
3. Choose the task you want to run from the list.
72
127
73
-
##### Verify database schema and data
128
+
##### 1. Verify database schema and data
74
129
75
130
This task opens the `verifyDatabase.sql` file in your workspace and executes the SQL query using the `ms-mssql.mssql` extension. This task is optional however it can help you to become familiar with the sample `Library` database tables and data included in this dev container template.
76
131
77
-
##### Build SQL Database project
132
+
##### 2. Build SQL Database project
78
133
79
134
This task builds the SQL Database project. It runs the command `dotnet build` in the `database/Library` directory of your workspace.
80
135
81
136
This task is optional, but it's useful to verify the database schema. You can use this SQL Database project to make changes to the database schema and deploy it to the SQL Server container.
82
137
83
-
#### Publish SQL Database project
138
+
##### 3. Publish SQL Database project
84
139
85
140
This task involves deploying the SQL Database project to your SQL Server container. It executes the `postCreateCommand.sh` script found in the `.devcontainer/sql` directory of your workspace.
86
141
87
142
The `postCreateCommand.sh` script requires one argument: the path to the directory containing the .dacpac file for the SQL Database project. In this scenario, that directory is `database/Library/bin/Debug`.
88
143
89
-
It utilizes the sqlpackage command-line utility to update the database schema using the .dacpac file, employing authentication credentials from the `.env` file situated in the `.devcontainer` directory.
144
+
It utilizes the `SqlPackage` command-line utility to update the database schema using the .dacpac file, employing authentication credentials from the `.devcontainer/.env` file.
90
145
91
-
##### Trust HTTPS certificate for .NET Aspire
146
+
##### 4. Update .NET SDK
92
147
93
-
This task trusts the HTTPS certificate for the .NET Aspire project. It runs the command `dotnet dev-certs https --trust`.
148
+
This task ensures that .NET Aspire uses the latest advancements and enhancements provided by the .NET ecosystem, enabling smoother development experiences and potentially addressing any compatibility issues with newer versions of .NET or its related components.
94
149
95
-
##### Update .NET SDK
150
+
##### 5. Trust HTTPS certificate for .NET
96
151
97
-
This task ensures that .NET Aspire uses the latest advancements and enhancements provided by the .NET ecosystem, enabling smoother development experiences and potentially addressing any compatibility issues with newer versions of .NET or its related components.
152
+
This task trusts the HTTPS certificate for the .NET Aspire project. It runs the command `dotnet dev-certs https --trust`.
98
153
99
154
### Changing the sa password
100
155
@@ -107,7 +162,7 @@ The password must comply with the following rules:
107
162
108
163
### Database deployment
109
164
110
-
By default, a demo database titled `Library` is created using a DAC package. The deployment process is automated through the `postCreateCommand.sh` script, which is specified in the devcontainer.json configuration:
165
+
By default, a demo database titled `Library` is created using a dacpac file. The deployment process is automated through the `postCreateCommand.sh` script, which is specified in the `devcontainer.json' configuration:
@@ -117,14 +172,19 @@ By default, a demo database titled `Library` is created using a DAC package. The
117
172
118
173
The `postCreateCommand.sh` script handles the database deployment by performing the following steps:
119
174
120
-
1. Loads the `SA_PASSWORD` from the `.env` file.
175
+
1. Loads the `SA_PASSWORD` from the `.devcontainer/.env` file.
121
176
1. Waits for the SQL Server to be ready by attempting to connect multiple times.
122
177
1. Checks for .dacpac files in the specified directory (`database/Library/bin/Debug`).
123
-
1. Deploys each .dacpac file found to the SQL Server.
178
+
1. Deploys each .dacpac file found to the database.
124
179
125
180
#### Using the SQL Database Projects Extension
126
181
127
-
You can use the SQL Database Projects extension to deploy the database schema. The `Library.sqlproj` project is located in the `database/Library` folder and can be built using the Build SQL Database project task. The output .dacpac files should be placed in the `./bin/Debug` folder for deployment.
182
+
To modify the database schema, utilize the SQL Database Projects extension. This allows you to build and publish changes directly from VS Code to your local database included in this development environment. Use the pre-built VS Code tasks for building (`2. Build SQL Database project`) and publishing (`3. Publish SQL Database project`). The build process will update the `.dacpac` file and the project definition, which is located in the `./bin/Debug` folder.
183
+
184
+
> [!TIP]
185
+
> With this demo project, you can easily use the dacpac artifact created by SQL Database Projects and deploy it to Azure SQL Database using the Azure SQL Action for GitHub Actions. This process streamlines your workflow and ensures seamless integration with your production environment.
186
+
187
+
To learn more about the SQL Database Projects extension, visit the [Getting started with the SQL Database Projects extension](/azure-data-studio/extensions/sql-database-project-extension-getting-started).
0 commit comments