{"id":22366191,"url":"https://github.com/microsoft/vscode-remote-try-sqlserver","last_synced_at":"2025-07-30T16:32:51.232Z","repository":{"id":61766341,"uuid":"539888650","full_name":"microsoft/vscode-remote-try-sqlserver","owner":"microsoft","description":"SQL Server and Azure SQL sample project for trying out the Dev Containers extension","archived":false,"fork":false,"pushed_at":"2023-03-09T11:22:15.000Z","size":28,"stargazers_count":39,"open_issues_count":3,"forks_count":17,"subscribers_count":26,"default_branch":"main","last_synced_at":"2024-12-04T17:49:41.909Z","etag":null,"topics":["docker","sql-server"],"latest_commit_sha":null,"homepage":"","language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2022-09-22T08:58:22.000Z","updated_at":"2024-11-30T21:27:51.000Z","dependencies_parsed_at":"2023-02-12T22:31:29.025Z","dependency_job_id":null,"html_url":"https://github.com/microsoft/vscode-remote-try-sqlserver","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-remote-try-sqlserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-remote-try-sqlserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-remote-try-sqlserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-remote-try-sqlserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/vscode-remote-try-sqlserver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228164525,"owners_count":17879084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","sql-server"],"created_at":"2024-12-04T18:08:06.652Z","updated_at":"2024-12-04T18:08:07.936Z","avatar_url":"https://github.com/microsoft.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Try Out Development Containers: SQL Server \u0026 Azure SQL\n\n[![Open in Remote - Containers](https://img.shields.io/static/v1?label=Remote%20-%20Containers\u0026message=Open\u0026color=blue\u0026logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-sqlserver)\n\nA **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)**.\n\nThis 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-\u0026type=Repositories) sample projects, too.\n\n\u003e **Note:** If you already have a Codespace or dev container, you can jump to the [Things to try](#things-to-try) section.\n\n\n## Setting up the development container\n\n### GitHub Codespaces\n\nFollow these steps to open this sample in a Codespaces:\n\n1. Click the Code drop-down menu and select the **Codespaces** tab.\n1. Click on **Create codespaces on main** at the bottom of the pane.\n\nFor 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).\n\n### VS Code Dev Containers\n\nIf 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.\n\nFollow these steps to open this sample in a container using the VS Code Dev Containers extension:\n\n1. 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).\n\n2. To use this repository, you can either open the repository in an isolated Docker volume:\n\n    - Press \u003ckbd\u003eF1\u003c/kbd\u003e and select the **Dev Containers: Try a Sample...** command.\n    - Choose the \".NET Core\" sample, wait for the container to start, and try things out!\n        \u003e **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.\n\n   Or open a locally cloned copy of the code:\n\n   - Clone this repository to your local filesystem.\n   - Press \u003ckbd\u003eF1\u003c/kbd\u003e and select the **Dev Containers: Open Folder in Container...** command.\n   - Select the cloned copy of this folder, wait for the container to start, and try things out!\n\n## Things to try\n\nOnce you have this sample opened, you'll be able to work with it like you would locally.\n\n\u003e **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.\n\n1. **Connect via SQLCMD and create a new database**\n\n    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.\n\n    ```sql\n    sqlcmd -S localhost -U sa -P P@ssw0rd -d master -i 01-CreateDatabase.sql\n    ```\n\n    \u003e 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).\n\n2. **Deploy schema with SQL Database projects**\n\n    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.\n\n    - On the primary sidebar (on the left), click on **Database projects** tab.\n    - 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 -\u003e Answer):\n        - Select where to publish the project to -\u003e Publish to an existing SQL server\n        - Select publish profile to load -\u003e Don't use profile\n        - Choose a connection profile from the list below -\u003e mssql-container\n        - Select database -\u003e TryDbProject\n        - Choose action -\u003e Publish\n    - After a minute or so, the database schema should be deployed. You can follow the deployment via the notification or through _Database Projects_ output. \n\n\u003e 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_ \u003e _Database Projects_.\n\n3. **Explore your database with SQL Server extension**\n\n    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.\n\n    - On the primary sidebar (on the left), click on **SQL Server** tab.\n    - The _SQL Server_ pane appears. You should already see `mssql-container` listed. Click on it\n    - Type the password listed previously\n    - 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.\n\n## Things to try with an Azure Subscription\n\nThis 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. \n\n\u003e 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). \n\n1. **Login to your Azure account and create resources**\n\n    - Open the terminal pane and type `az login --use-device-code`. Follow the instructions\n    - Once logged-in, execute `./infrastructure/createAzureSQLServer.sh`\n    - Copy the connection string, this will be necessary in the next step.\n\n    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**. \n    \n    \u003eRemember to execute the Cleanup step below to avoid excessive billing.\n\n2. **Prepare database project and deploy it to Azure**\n\n    - On the primary sidebar (on the left), click on **Database projects** tab.\n    - The _Database Projects_ pane appears. The `TryDbProjects` project shows up.\n    - Right click on the project name, and click on **Change target platform**, and select **Azure SQL Database**\n    - You can now deploy the database schema like you've done in the previous example, by using the connection string generated in step 1.\n\n    Your database schema will be published. You can go back on the **SQL Server** Pane to explore it.\n\n3. Cleanup Azure resources\n\n    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`\n\n\u003e **About Azure Billing**\n\u003e 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/).\n\u003e \n\u003e As a good practice, in cloud environments, you should delete resources you don't use.\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## License\n\nCopyright © Microsoft Corporation All rights reserved.\u003cbr /\u003e\nLicensed under the MIT License. See LICENSE in the project root for license information.\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft \ntrademarks or logos is subject to and must follow \n[Microsoft's Trademark \u0026 Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-remote-try-sqlserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fvscode-remote-try-sqlserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-remote-try-sqlserver/lists"}