├── TryDbProjects
├── Users.sql
├── TryDbProjects.sqlproj
└── Script.PostDeployment.InsertUsers.sql
├── 01-CreateDatabase.sql
├── CODE_OF_CONDUCT.md
├── .devcontainer
├── mssql
│ ├── installSQLtools.sh
│ └── postCreateCommand.sh
├── Dockerfile
├── docker-compose.yml
└── devcontainer.json
├── LICENSE
├── SUPPORT.md
├── infrastructure
└── createAzureSQLServer.sh
├── SECURITY.md
├── .gitignore
└── README.md
/TryDbProjects/Users.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [dbo].[Users]
2 | (
3 | [Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY NONCLUSTERED DEFAULT newid(),
4 | [FirstName] NVARCHAR(100) NOT NULL,
5 | [LastName] NVARCHAR(100),
6 | [Email] NVARCHAR(200)
7 | )
8 |
--------------------------------------------------------------------------------
/01-CreateDatabase.sql:
--------------------------------------------------------------------------------
1 | -- Create a new database called 'DatabaseName'
2 | -- Connect to the 'master' database to run this snippet
3 | USE master
4 | GO
5 | -- Create the new database if it does not exist already
6 | IF NOT EXISTS (
7 | SELECT name
8 | FROM sys.databases
9 | WHERE name = N'TrySQLCMD'
10 | )
11 | CREATE DATABASE TrySQLCMD
12 | GO
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/TryDbProjects/TryDbProjects.sqlproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | TryDbProjects
6 | {25AAD799-765E-498D-9606-9065C455E68B}
7 | Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider
8 | 1033, CI
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.devcontainer/mssql/installSQLtools.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "Installing mssql-tools"
3 | curl -sSL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT)
4 | DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
5 | CODENAME=$(lsb_release -cs)
6 | echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
7 | apt-get update
8 | ACCEPT_EULA=Y apt-get -y install unixodbc-dev msodbcsql17 libunwind8 mssql-tools
9 |
10 | echo "Installing sqlpackage"
11 | curl -sSL -o sqlpackage.zip "https://aka.ms/sqlpackage-linux"
12 | mkdir /opt/sqlpackage
13 | unzip sqlpackage.zip -d /opt/sqlpackage
14 | rm sqlpackage.zip
15 | chmod a+x /opt/sqlpackage/sqlpackage
16 |
--------------------------------------------------------------------------------
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | # [Choice] .NET version: 6.0-focal, 3.1-focal
2 | ARG VARIANT="6.0-focal"
3 | FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT}
4 |
5 | # Add .NET global tools path
6 | ENV PATH $PATH:/home/vscode/.dotnet:/home/vscode/.dotnet/tools
7 |
8 | # [Choice] Node.js version: none, lts/*, 18, 16, 14
9 | ARG NODE_VERSION="none"
10 | RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11 |
12 | # Install SQL Tools: SQLPackage and sqlcmd
13 | COPY mssql/installSQLtools.sh installSQLtools.sh
14 | RUN bash ./installSQLtools.sh \
15 | && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
16 |
17 | # [Optional] Uncomment this section to install additional OS packages.
18 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19 | # && apt-get -y install --no-install-recommends
20 |
21 | # [Optional] Uncomment this line to install global node packages.
22 | # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/.devcontainer/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | app:
5 | build:
6 | context: .
7 | dockerfile: Dockerfile
8 | args:
9 | # Update 'VARIANT' to pick a version of .NET: 3.1-focal, 6.0-focal
10 | VARIANT: "6.0-focal"
11 | # Optional version of Node.js
12 | NODE_VERSION: "none"
13 |
14 | volumes:
15 | - ..:/workspace:cached
16 |
17 | # Overrides default command so things don't shut down after the process ends.
18 | command: sleep infinity
19 |
20 | # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
21 | network_mode: service:db
22 | # Uncomment the next line to use a non-root user for all processes.
23 | # user: vscode
24 |
25 | # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
26 | # (Adding the "ports" property to this file will not forward from a Codespace.)
27 |
28 | db:
29 | image: mcr.microsoft.com/mssql/server:2022-latest
30 | restart: unless-stopped
31 | environment:
32 | SA_PASSWORD: P@ssw0rd
33 | ACCEPT_EULA: Y
34 | # Add "forwardPorts": ["1433"] to **devcontainer.json** to forward MSSQL locally.
35 | # (Adding the "ports" property to this file will not forward from a Codespace.)
36 |
--------------------------------------------------------------------------------
/SUPPORT.md:
--------------------------------------------------------------------------------
1 | # TODO: The maintainer of this repo has not yet edited this file
2 |
3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
4 |
5 | - **No CSS support:** Fill out this template with information about how to file issues and get help.
6 | - **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps.
7 | - **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide.
8 |
9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
10 |
11 | # Support
12 |
13 | ## How to file issues and get help
14 |
15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing
16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or
17 | feature request as a new Issue.
18 |
19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
22 |
23 | ## Microsoft Support Policy
24 |
25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
26 |
--------------------------------------------------------------------------------
/infrastructure/createAzureSQLServer.sh:
--------------------------------------------------------------------------------
1 | # Create a single database and configure a firewall rule
2 | # Variable block
3 | let "randomIdentifier=$RANDOM*$RANDOM"
4 | location="East US"
5 | resourceGroup="rg-trycontainer-azuresql-$randomIdentifier"
6 | server="trycontainer-azuresql-server-$randomIdentifier"
7 | database="trycontazuresqldb$randomIdentifier"
8 | login="azureuser"
9 | password="Pa$$w0rD-$randomIdentifier"
10 | # Specify appropriate IP address values for your environment
11 | # to limit access to the SQL Database server
12 | startIp=0.0.0.0
13 | endIp=0.0.0.0
14 |
15 | echo "Using resource group $resourceGroup with login: $login, password: $password..."
16 | echo "Creating $resourceGroup in $location..."
17 | az group create --name $resourceGroup --location "$location"
18 | echo "Creating $server in $location..."
19 | az sql server create --name $server --resource-group $resourceGroup --location "$location" --admin-user $login --admin-password $password
20 | echo "Configuring firewall..."
21 | az sql server firewall-rule create --resource-group $resourceGroup --server $server -n AllowYourIp --start-ip-address $startIp --end-ip-address $endIp
22 | echo "Creating $database on $server..."
23 | az sql db create --resource-group $resourceGroup --server $server --name $database --edition GeneralPurpose --family Gen5 --capacity 2 --compute-model Serverless --auto-pause-delay 60
24 | connectionString=$(az sql db show-connection-string -s $server -n $database -c ado.net)
25 | connectionString=${connectionString///$login}
26 | connectionString=${connectionString///$password}
27 | echo "Database created on $resourceGroup. ConnectionString:"
28 | echo "$connectionString"
29 | echo "To clean-up resources, type az group delete --name $resourceGroup"
--------------------------------------------------------------------------------
/.devcontainer/mssql/postCreateCommand.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | dacpac="false"
3 | sqlfiles="false"
4 | SApassword=$1
5 | dacpath=$2
6 | sqlpath=$3
7 |
8 | echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql
9 | for i in {1..60};
10 | do
11 | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i testsqlconnection.sql > /dev/null
12 | if [ $? -eq 0 ]
13 | then
14 | echo "SQL server ready"
15 | break
16 | else
17 | echo "Not ready yet..."
18 | sleep 1
19 | fi
20 | done
21 | rm testsqlconnection.sql
22 |
23 | for f in $dacpath/*
24 | do
25 | if [ $f == $dacpath/*".dacpac" ]
26 | then
27 | dacpac="true"
28 | echo "Found dacpac $f"
29 | fi
30 | done
31 |
32 | for f in $sqlpath/*
33 | do
34 | if [ $f == $sqlpath/*".sql" ]
35 | then
36 | sqlfiles="true"
37 | echo "Found SQL file $f"
38 | fi
39 | done
40 |
41 | if [ $sqlfiles == "true" ]
42 | then
43 | for f in $sqlpath/*
44 | do
45 | if [ $f == $sqlpath/*".sql" ]
46 | then
47 | echo "Executing $f"
48 | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i $f
49 | fi
50 | done
51 | fi
52 |
53 | if [ $dacpac == "true" ]
54 | then
55 | for f in $dacpath/*
56 | do
57 | if [ $f == $dacpath/*".dacpac" ]
58 | then
59 | dbname=$(basename $f ".dacpac")
60 | echo "Deploying dacpac $f"
61 | /opt/sqlpackage/sqlpackage /Action:Publish /SourceFile:$f /TargetServerName:localhost /TargetDatabaseName:$dbname /TargetUser:sa /TargetPassword:$SApassword
62 | fi
63 | done
64 | fi
65 |
66 | if [ $SApassword == "P@ssw0rd" ]
67 | then
68 | echo "$(tput setaf 1)WARNING$(tput sgr0): you are using the default sample password. If you want to change it, execute the following command"
69 | echo "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -Q \"ALTER LOGIN sa WITH PASSWORD = '' \""
70 | fi
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/dotnet-mssql
3 | {
4 | "name": "C# (.NET) and MS SQL",
5 | "dockerComposeFile": "docker-compose.yml",
6 | "service": "app",
7 | "workspaceFolder": "/workspace",
8 |
9 | // Configure tool-specific properties.
10 | "customizations": {
11 | // Configure properties specific to VS Code.
12 | "vscode": {
13 | // Set *default* container specific settings.json values on container create.
14 | "settings": {
15 | "mssql.connections": [
16 | {
17 | "server": "localhost,1433",
18 | "database": "",
19 | "authenticationType": "SqlLogin",
20 | "user": "sa",
21 | "password": "P@ssw0rd",
22 | "emptyPasswordInput": false,
23 | "savePassword": false,
24 | "profileName": "mssql-container"
25 | }
26 | ],
27 | "sqlDatabaseProjects.dotnetSDK Location": "/usr/bin/"
28 | },
29 | // Add the IDs of extensions you want installed when the container is created.
30 | "extensions": [
31 | "ms-dotnettools.csharp",
32 | "ms-mssql.mssql"
33 | ]
34 | }
35 | },
36 | "features": {
37 | "ghcr.io/devcontainers/features/azure-cli:1": {
38 | "version": "latest"
39 | }
40 | },
41 | // Use 'forwardPorts' to make a list of ports inside the container available locally.
42 | // "forwardPorts": [5000, 5001],
43 |
44 | // [Optional] To reuse of your local HTTPS dev cert:
45 | //
46 | // 1. Export it locally using this command:
47 | // * Windows PowerShell:
48 | // dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
49 | // * macOS/Linux terminal:
50 | // dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
51 | //
52 | // 2. Uncomment these 'remoteEnv' lines:
53 | // "remoteEnv": {
54 | // "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
55 | // "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
56 | // },
57 | //
58 | // 3. Next, copy your certificate into the container:
59 | // 1. Start the container
60 | // 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
61 | // 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
62 |
63 | // postCreateCommand.sh parameters: $1=SA password, $2=dacpac path, $3=sql script(s) path
64 | "postCreateCommand": "bash .devcontainer/mssql/postCreateCommand.sh 'P@ssw0rd' './bin/Debug/' './.devcontainer/mssql/'",
65 | "remoteEnv": {
66 | "PATH": "${containerEnv:PATH}:/opt/mssql-tools/bin"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/TryDbProjects/Script.PostDeployment.InsertUsers.sql:
--------------------------------------------------------------------------------
1 | IF (SELECT COUNT(*) from dbo.Users ) = 0
2 |
3 | INSERT INTO dbo.Users
4 | (
5 | [Id],
6 | [FirstName],
7 | [LastName],
8 | [Email]
9 | )
10 | VALUES
11 | ('181E26CF-92C1-C65E-2D2B-E290BAB441B4','Quyn','Burke','curabitur@yahoo.edu'),
12 | ('74FAB56A-6453-C88F-6538-51448147252E','Yoshi','Jordan','lectus.convallis@outlook.ca'),
13 | ('E9FA0E1C-426F-6EC0-812A-AADDB856F3E7','Naida','Stevens','egestas@aol.edu'),
14 | ('5281A17E-BB41-BB15-9153-AA7813F6B539','Kenyon','England','in.tempus.eu@aol.edu'),
15 | ('AB54C533-E3E3-ECD0-335C-845249D37DED','Janna','Dale','duis@aol.org'),
16 | ('E3C12A5C-E0CB-E80A-B153-54D939D4DDDC','Declan','Robbins','enim@hotmail.edu'),
17 | ('CB7D4A67-FB95-3286-D3FE-7315353A4B98','Brittany','Swanson','euismod.est@protonmail.com'),
18 | ('39443FCA-FCF5-C93F-7D54-95BB5213C298','Zeph','Silva','blandit.congue.in@google.ca'),
19 | ('1CCD843A-D667-1DF7-927C-7977AD9C5AA5','Jakeem','Knapp','ac.mattis@aol.net'),
20 | ('AA69AB6E-AE62-D175-1BD6-98DB04E2D56E','Joy','Albert','nulla.interdum.curabitur@hotmail.com'),
21 | ('458B53B7-80AD-1118-8072-C9A0A12473D5','Griffith','Cortez','sit.amet@google.com'),
22 | ('D0D9C807-28A0-CE91-DE85-78521343E41A','Vincent','Day','mi.felis@outlook.com'),
23 | ('83C28FDB-B94F-C221-D03C-8377D144D977','Libby','Burnett','dui.in.sodales@hotmail.couk'),
24 | ('7E341D9D-987C-EC5D-5B8B-DD4754E9194C','Melinda','Johnston','montes@yahoo.ca'),
25 | ('22A09411-6451-D969-0FDD-D4E919452693','Dai','Bates','vulputate.posuere@hotmail.net'),
26 | ('743A7C84-7A8A-BDC7-427D-7A768998943B','Darrel','Mendoza','sem@google.ca'),
27 | ('53E614CD-3717-2CC6-9B7A-A5979F487D4C','Bryar','Stokes','risus.duis@aol.edu'),
28 | ('37602924-4EBC-2223-A8CD-D1B7CC02A9A8','Lyle','White','aliquet.diam@protonmail.couk'),
29 | ('ACEF652D-BB13-E48B-8E93-3CE25D5E18AA','Paloma','Dodson','ut@protonmail.com'),
30 | ('66411AE8-B4EE-4A99-EBA0-C2D9DE70AED4','Azalia','Cotton','a.aliquet@icloud.ca'),
31 | ('4A8ECA9F-A9FE-651C-A970-1CCD1C8E52AB','Alexander','Hatfield','quam.curabitur@outlook.edu'),
32 | ('3F75CAC8-AC19-41FA-AF4A-DE5D5B198A5B','TaShya','Hendricks','donec.vitae@google.ca'),
33 | ('A858EFE4-3AD6-DD3A-825B-E6E3E1399BC0','Amery','Padilla','dui@protonmail.edu'),
34 | ('D321C13E-A74B-1A7A-DD6C-1D8C64466AEE','Jack','Gallegos','mollis.duis@hotmail.org'),
35 | ('22538752-3F75-3C15-49D7-8C9068487DE7','Arden','Oneil','ac.turpis.egestas@aol.org'),
36 | ('C91EEA17-C54E-551B-BB51-9D959DFA42D3','Malik','Allison','quis@aol.com'),
37 | ('63C204EE-7416-0BFC-6737-AB3DDD5EC13B','Duncan','Colon','egestas.lacinia@protonmail.ca'),
38 | ('72532D5B-B677-16E3-35E4-BAC634B2B556','Adena','Lynn','consectetuer@protonmail.com'),
39 | ('A27F65E8-C94C-382D-A23D-8D51941585BD','Eleanor','Stuart','sed.eu.eros@icloud.org'),
40 | ('547184BA-0D28-5FE5-5378-7C3571B6F44F','Jasper','Travis','arcu.vestibulum@outlook.edu'),
41 | ('5AA47D69-C0CA-771D-5375-8582C42F9C74','Julien','Dubois','jdubois@wanadoo.fr'),
42 | ('969F218B-4268-0B3B-71D7-ACD41555DB28','Castor','Howard','tincidunt.tempus.risus@yahoo.edu'),
43 | ('CD59556A-B78F-9C9A-DB61-A5B9811C012A','Baxter','Conway','donec.tempor@outlook.net'),
44 | ('B71F4826-3CE3-B343-9DDE-3727713EA7AD','Leo','Compton','a.purus.duis@outlook.net'),
45 | ('7F3D9AE8-8634-9E9F-C2BA-BAB839ECA48A','Boris','Knight','diam.at@icloud.net'),
46 | ('19758A5C-CE6D-5BDD-540F-90CD2DCCEA2A','Boris','Wilcox','imperdiet@hotmail.org'),
47 | ('26E7F62F-E51A-EF4C-551C-43C8324B2318','Caleb','Stokes','mauris.erat@icloud.edu'),
48 | ('6836D721-A828-21BE-5670-58681EAE925A','Walker','Forbes','id.ante@hotmail.ca'),
49 | ('9E9D4731-920C-AFCA-1344-84E27C5E359E','Kenneth','Mason','consectetuer.adipiscing.elit@yahoo.com'),
50 | ('E86D9864-4B88-5DF8-1A67-1D0DB5D2D036','Blythe','Glenn','et@outlook.ca'),
51 | ('9BEC252D-487A-3CB9-CF77-9C31AA3665E1','Ivory','Cooper','sed@google.ca'),
52 | ('495F725E-D4AC-EC18-E2A5-81AC77763750','Nelle','Singleton','dolor.fusce.mi@icloud.ca'),
53 | ('3CE456B0-3E1E-BE67-3AE8-8FCE5C9B2E8E','Erasmus','Gould','eget@aol.net'),
54 | ('A15E9A75-E594-14C3-5A44-EE1BA851BE2C','Hayfa','Rodriguez','pede@outlook.net'),
55 | ('76511A22-B594-4CF8-1052-0D87FF4FA638','Barbara','Shaffer','turpis.egestas@google.org'),
56 | ('DA8ACD3E-8551-9EB1-A0A2-59614649A242','Channing','Williams','sed@hotmail.net'),
57 | ('D12DC64E-FF9A-B1D2-17BA-02949D333793','Ferris','Gray','bibendum@icloud.org'),
58 | ('A959CBB6-57B2-46C0-0362-172D9B4FAB07','Sawyer','Burgess','luctus@hotmail.couk'),
59 | ('EE9D6998-51EE-854A-A5DA-51A390B36863','Signe','Witt','rutrum.urna@aol.edu'),
60 | ('A7408BA5-D6FB-155E-CA62-9E95BA9B5AE5','Ray','Madden','aliquet@protonmail.edu'),
61 | ('019CB502-6A1C-6573-8349-7526C54A3BD1','Kermit','Vang','ac.mattis.ornare@icloud.edu'),
62 | ('692B5883-9B53-6899-B3DA-62D2EC1573AD','Karly','Trevino','neque.in@aol.couk'),
63 | ('878D4C9E-EBAE-FBAD-693C-86DAE189E5C8','Xavier','Banks','ac@hotmail.couk'),
64 | ('130D6835-CAD6-80CB-6594-580C0D761945','Ainsley','Sellers','lectus.convallis.est@outlook.ca'),
65 | ('59DB4012-C0A2-B875-5284-4BE6B1BD1C14','Tanek','Romero','et.ultrices@protonmail.com'),
66 | ('95641C23-F3CA-A2B6-E950-254497EC2101','Vincent','Sutton','malesuada.fringilla@protonmail.net'),
67 | ('62495AE6-6945-BAF3-5AC7-49F64D8827E9','Camilla','Ochoa','risus.a@google.org'),
68 | ('8C38E7CD-D41C-DB1D-76A8-187524D8A44D','Hall','Cash','orci.ut@google.org'),
69 | ('C712E8CC-55DF-484B-5875-5C71CB55EAA1','Guy','Mullins','mauris@outlook.edu'),
70 | ('CB16C73F-CA4E-BF4F-638C-D30A330B834E','Brody','Workman','urna.suscipit@hotmail.com'),
71 | ('B6BAC6D4-DC06-AB90-E936-5687BBA5B77E','Harrison','Shannon','aliquam.ornare.libero@google.edu'),
72 | ('DBF3E3C6-BC39-6F9A-D636-97109EB5152E','Tobias','Norman','odio@yahoo.ca'),
73 | ('E4254B41-1A4C-3D88-248D-D67B9F67957C','Kasper','Hamilton','ultrices.posuere@hotmail.org'),
74 | ('C2467B56-ED1B-C0A3-5CA6-917C6D9C7AAA','Cruz','Duffy','mauris.vestibulum@yahoo.org'),
75 | ('3B428289-1C25-6C69-E1C2-59BB06A80CD8','Irene','Mcfarland','pellentesque.eget@protonmail.ca'),
76 | ('23ABBCC5-4429-3D2C-749B-B768CD474DA2','Michael','Zamora','tincidunt.vehicula@icloud.net'),
77 | ('A9A583D5-C0E3-59EC-4AA1-6D242CBC65A3','Kiayada','Lang','at@google.net'),
78 | ('4663B5E9-DCAF-D44A-1781-1155711DD237','McKenzie','Hoffman','tincidunt.congue@icloud.couk'),
79 | ('FC1C3C72-2A66-B132-8631-9CDAC1B8A50D','Ursula','Allen','ante.ipsum.primis@protonmail.ca'),
80 | ('236D4ECD-4D55-D29C-4744-A5E8BC72BB41','Raymond','Carney','magna.a@google.edu'),
81 | ('2BB79A77-077D-E383-A18C-2B3F6EE5075D','Barrett','Wiggins','fermentum.vel.mauris@google.ca'),
82 | ('18D7545B-E327-B71B-28B5-265F722F8CDF','Athena','Acosta','ultrices.iaculis.odio@yahoo.com'),
83 | ('56CE133F-15AD-DD94-874D-4B32883BEBBC','Dylan','Hooper','non.magna@aol.ca'),
84 | ('72D08C41-2B87-C765-FB67-E84ABE877C78','Wang','Castaneda','diam.proin@aol.couk'),
85 | ('26174B6E-6C10-840C-6189-CE1E4949E94B','Maggy','Rowland','pede@hotmail.org'),
86 | ('5937146B-B936-AEA7-96BC-A564BB5EE7A2','Kylee','Finch','eget@aol.org'),
87 | ('D6E3306A-EBA1-A77A-8CD2-37E831B84DB7','Martin','Melton','non.nisi@google.com'),
88 | ('AC72BB2A-4CCE-C5B4-4FB7-5165C0CCA34A','Sydnee','Pollard','sollicitudin@outlook.net'),
89 | ('48EE8C7C-C2E8-E90C-E83F-B3239E1BA895','Eugenia','Stewart','vitae.sodales@google.ca'),
90 | ('968BC2B1-4CF6-A9A7-8954-D7BD108AE1F7','Myra','Young','mauris.id.sapien@aol.net'),
91 | ('2B847DA5-5517-9F76-AE9D-CC90D4088CCF','Karleigh','Melton','massa@google.com'),
92 | ('AB8AB444-5A33-677B-E95B-431C742F8123','Driscoll','Dennis','libero.lacus.varius@yahoo.ca'),
93 | ('DB9E8D5D-6191-8F81-8751-344F89896B4C','Gage','Maldonado','ac.tellus@protonmail.com'),
94 | ('52BEBA27-195A-E627-DAA9-297BCE100C78','Lee','Becker','dictum.mi.ac@protonmail.com'),
95 | ('B5A6B51F-D929-A22C-BB8A-86541311313E','Leonard','Burnett','nisi@yahoo.net'),
96 | ('858D3B50-7CC9-A537-5C49-2855CB88E44E','Zena','Leblanc','volutpat@aol.edu'),
97 | ('1AAD35D9-9F63-5399-EB3D-DE61315EB623','Samuel','Hardy','quis.arcu.vel@outlook.com'),
98 | ('7F49E6CC-8786-4E4C-23EA-F13DC035A596','Jin','Lara','purus@hotmail.org'),
99 | ('DC09F6BA-347C-6133-D36C-6EE2057612C7','Lane','Sykes','elit.curabitur@outlook.ca'),
100 | ('C187BB23-9421-2E71-6A4F-7D7A125074CF','Reed','Collier','nunc.nulla@outlook.com'),
101 | ('2E23B5CA-B1B9-B855-48EF-A384F26A2D4A','Bethany','Hooper','rutrum.non.hendrerit@outlook.couk'),
102 | ('AF2DEAAB-8879-5C96-B9D7-AA86D97E2466','Evangeline','Solomon','fringilla.mi@hotmail.couk'),
103 | ('AE113F29-C475-AA25-3B5B-93673FA7CE09','Jessica','Henry','lacus.quisque.imperdiet@outlook.couk'),
104 | ('DAB18155-D581-CA6D-1DD4-1185C131CE3F','Olga','Melton','hendrerit.donec.porttitor@yahoo.org'),
105 | ('97753E7D-D881-BCF0-8239-148BD02BB997','Gabriel','Vega','lacus.quisque@outlook.couk'),
106 | ('F7B2D5F8-94C1-787F-1AAF-8D33E1273639','Rhonda','Coleman','congue.in@icloud.ca'),
107 | ('5139D96C-8CAC-D294-CAE2-95EC878AC182','Josiah','Avery','lectus@icloud.net'),
108 | ('9E2F9D14-1C19-CD77-6323-987BC048EC21','Maxwell','Blevins','urna.et@aol.com'),
109 | ('5AB1ACAD-5C47-B15F-5587-42ED1A28A82B','Harriet','Williams','in.tempus@protonmail.org'),
110 | ('68DA2F2A-A1BB-B84A-ED61-7C61B45918DD','Hayden','Summers','malesuada.fames@hotmail.couk');
111 | GO
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Try Out Development Containers: SQL Server & Azure SQL
2 |
3 | [](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-sqlserver)
4 |
5 | A **development container** is a running [Docker](https://www.docker.com) container with a well-defined tool/runtime stack and its prerequisites. You can try out development containers with **[GitHub Codespaces](https://github.com/features/codespaces)** or **[Visual Studio Code Remote - Containers](https://aka.ms/vscode-remote/containers)**.
6 |
7 | This is a sample project that lets you try out either option in a few easy steps. We have a variety of other [vscode-remote-try-*](https://github.com/search?q=org%3Amicrosoft+vscode-remote-try-&type=Repositories) sample projects, too.
8 |
9 | > **Note:** If you already have a Codespace or dev container, you can jump to the [Things to try](#things-to-try) section.
10 |
11 |
12 | ## Setting up the development container
13 |
14 | ### GitHub Codespaces
15 |
16 | Follow these steps to open this sample in a Codespaces:
17 |
18 | 1. Click the Code drop-down menu and select the **Codespaces** tab.
19 | 1. Click on **Create codespaces on main** at the bottom of the pane.
20 |
21 | 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).
22 |
23 | ### VS Code Dev Containers
24 |
25 | If you already have VS Code and Docker installed, you can click the badge above or [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-sqlserver) to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
26 |
27 | Follow these steps to open this sample in a container using the VS Code Dev Containers extension:
28 |
29 | 1. If this is your first time using a development container, please ensure your system meets the pre-reqs (i.e. have Docker installed) in the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started).
30 |
31 | 2. To use this repository, you can either open the repository in an isolated Docker volume:
32 |
33 | - Press F1 and select the **Dev Containers: Try a Sample...** command.
34 | - Choose the ".NET Core" sample, wait for the container to start, and try things out!
35 | > **Note:** 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.
36 |
37 | Or open a locally cloned copy of the code:
38 |
39 | - Clone this repository to your local filesystem.
40 | - Press F1 and select the **Dev Containers: Open Folder in Container...** command.
41 | - Select the cloned copy of this folder, wait for the container to start, and try things out!
42 |
43 | ## Things to try
44 |
45 | Once you have this sample opened, you'll be able to work with it like you would locally.
46 |
47 | > **Note:** This container runs as a non-root user with sudo access by default. Comment out `"remoteUser": "vscode"` in `.devcontainer/devcontainer.json` if you'd prefer to run as root.
48 |
49 | 1. **Connect via SQLCMD and create a new database**
50 |
51 | SQLCMD is already installed within the container. You can use it from the **Terminal** tab, using the *bash* shell. For example, you can execute a SQL Script. This example creates a new database.
52 |
53 | ```sql
54 | sqlcmd -S localhost -U sa -P P@ssw0rd -d master -i 01-CreateDatabase.sql
55 | ```
56 |
57 | > Note: The SQL Server instance is created with user `sa` and password `P@ssw0rd`. You will need it for the next steps. This password is defined in the `devcontainer.json` file. This password is not secure. It could be used in local development scenarios but must not be used elsewhere (hosted team development server, or production server).
58 |
59 | 2. **Deploy schema with SQL Database projects**
60 |
61 | SQL Server Database projects allow you to organize the code artifacts, generate a dacpac, or easily deploy schema changes on an instance. In this repository, you'll find a sample Database project that creates a single `User` table and populate it with some records. Let's deploy it on the SQL Instance integrated into the dev container.
62 |
63 | - On the primary sidebar (on the left), click on **Database projects** tab.
64 | - The _Database Projects_ pane appears. The `TryDbProjects` project shows up. You can just right-click the database project name and click **Publish**. You'll have a series of prompts. Answer with these items (Prompt -> Answer):
65 | - Select where to publish the project to -> Publish to an existing SQL server
66 | - Select publish profile to load -> Don't use profile
67 | - Choose a connection profile from the list below -> mssql-container
68 | - Select database -> TryDbProject
69 | - Choose action -> Publish
70 | - After a minute or so, the database schema should be deployed. You can follow the deployment via the notification or through _Database Projects_ output.
71 |
72 | > Note: you might have to update the extension setting _dotnet SDK location_ to `/usr/bin/` to execute the publish step. This setting is called _Dotnet SQL Location_ under _Extensions_ > _Database Projects_.
73 |
74 | 3. **Explore your database with SQL Server extension**
75 |
76 | SQL Server extension allows you to explore your SQL Server and Azure SQL instances right within Visual Studio Code. Let's explore the database we have just created.
77 |
78 | - On the primary sidebar (on the left), click on **SQL Server** tab.
79 | - The _SQL Server_ pane appears. You should already see `mssql-container` listed. Click on it
80 | - Type the password listed previously
81 | - The treeview will be populated with Database items. For example, you can explore the tables or even select the rows in the `dbo.Users` table created with the SQL Database project at the previous step.
82 |
83 | ## Things to try with an Azure Subscription
84 |
85 | This dev container uses the Azure CLI [dev container feature](https://github.com/devcontainers/features), that allows to interact with your Azure subscription. Here we will create a new Azure SQL Server and deploy our schema onto it.
86 |
87 | > Note: In this example, we use the Azure CLI to create our Azure resources. In a production environment, we would probably rely on Infrastructure tools like [Bicep](https://learn.microsoft.com/azure/azure-resource-manager/bicep/overview?tabs=bicep).
88 |
89 | 1. **Login to your Azure account and create resources**
90 |
91 | - Open the terminal pane and type `az login --use-device-code`. Follow the instructions
92 | - Once logged-in, execute `./infrastructure/createAzureSQLServer.sh`
93 | - Copy the connection string, this will be necessary in the next step.
94 |
95 | This script will create an Azure SQL logical server, an Azure SQL Database, and will create a firewall rule opening the traffic to the whole Internet. **You should not use this script for production scenarios**.
96 |
97 | >Remember to execute the Cleanup step below to avoid excessive billing.
98 |
99 | 2. **Prepare database project and deploy it to Azure**
100 |
101 | - On the primary sidebar (on the left), click on **Database projects** tab.
102 | - The _Database Projects_ pane appears. The `TryDbProjects` project shows up.
103 | - Right click on the project name, and click on **Change target platform**, and select **Azure SQL Database**
104 | - You can now deploy the database schema like you've done in the previous example, by using the connection string generated in step 1.
105 |
106 | Your database schema will be published. You can go back on the **SQL Server** Pane to explore it.
107 |
108 | 3. Cleanup Azure resources
109 |
110 | The scripts executed in step 1 creates Azure resources on your subscription. This will incur some billing. Once you've finished trying this feature, you can simply delete the created resource group. The Azure CLI command to execute is displayed on step 1. It looks like `az group delete --name resourceGroup`
111 |
112 | > **About Azure Billing**
113 | > In this example, we are using the [Serverless compute tier](https://learn.microsoft.com/en-us/azure/azure-sql/database/serverless-tier-overview?view=azuresql) of Azure SQL. This should incur a maximum billing of few euros if used for an hour. Depending on your subscription, you can leverage the [Azure Free Tier](https://azure.microsoft.com/free/).
114 | >
115 | > As a good practice, in cloud environments, you should delete resources you don't use.
116 |
117 | ## Contributing
118 |
119 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
120 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
121 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
122 |
123 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
124 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
125 | provided by the bot. You will only need to do this once across all repos using our CLA.
126 |
127 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
128 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
129 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
130 |
131 | ## License
132 |
133 | Copyright © Microsoft Corporation All rights reserved.
134 | Licensed under the MIT License. See LICENSE in the project root for license information.
135 |
136 | ## Trademarks
137 |
138 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
139 | trademarks or logos is subject to and must follow
140 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
141 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
142 | Any use of third-party trademarks or logos are subject to those third-party's policies.
143 |
--------------------------------------------------------------------------------