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
title: Deploy SQL Server in a container via Notebook
3
+
description: This tutorial shows how you can deploy SQL Server in a container.
4
+
author: dzsquared
5
+
ms.author: drskwier
6
+
ms.reviewer: markingmyname
7
+
ms.topic: tutorial
8
+
ms.prod: azure-data-studio
9
+
ms.technology: azure-data-studio
10
+
ms.custom:
11
+
- intro-deployment
12
+
ms.date: 7/22/2022
13
+
---
14
+
15
+
# Deploy SQL Server in a container using Azure Data Studio
16
+
17
+
You can deploy SQL Server in a container using Azure Data Studio through the deployment wizard and notebooks.
18
+
19
+
## Pre-requisites
20
+
21
+
-[Azure Data Studio](download-azure-data-studio.md) is installed
22
+
- Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. For more information, see [Install Docker](https://docs.docker.com/engine/installation/)
23
+
24
+
## Use the deployment wizard
25
+
26
+
Follow these steps to use the deployment wizard, which will guide you through the required settings in a simple UI experience.
27
+
28
+
First, find and select Azure SQL Database in the deployment wizard.
29
+
30
+
1. In Azure Data Studio, select the Connections viewlet on the left-side navigation.
31
+
2. Select the **...** button at the top of the Connections panel and choose **New Deployment...**
32
+
3. In the deployment wizard, select the **SQL Server container image** tile and select **Select** to move to the next screen.
33
+
4. In the Version dropdown, select which image of SQL Server you would like to deploy. The wizard will check whether you have a running instance of Docker at this time. Select **Select** to move to the next screen.
34
+
5. Enter the container name, a password for the *sa* account of suitable complexity (at least eight characters long and contain characters from three of the following four sets: uppercase letters, lowercase letters, base-10 digits, and symbols), and the port in the host environment which the container will map to.
35
+
6. Review the parameters you have entered and then select **Open Notebook**.
36
+
37
+
Once the Notebook opens, you can review the content and the code and make changes if you like. However, be aware that any changes you make to the Notebook could potentially cause validation errors.
38
+
39
+
The last step is to select **Run all** to run all cells in the Notebook. Once this completes you should have a fully created and running SQL Database that you can connect to and query from ADS.
40
+
41
+
## Next steps
42
+
43
+
After you've created your database, server, or pool, you can [connect and query](quickstart-sql-database.md) your database in Azure Data Studio.
44
+
45
+
For more information on deploying SQL Server in containers, see [Quickstart: Run SQL Server Linux container images with Docker](../linux/quickstart-install-connect-docker.md).
[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
22
-
It is a good practice to review the contents of a DAC package before deploying it in production, and to validate the upgrade actions before upgrading an existing DAC. This is especially true when deploying packages that were not developed in your organization.
23
-
24
-
1.**Before you begin:**[Prerequisites](#Prerequisites)
25
-
26
-
2.**To upgrade a DAC, using:**[View the Contents of a DAC](#ViewDACContents), [View Database Changes](#ViewDBChanges), [View Upgrade Actions](#ViewUpgradeActions), [Compare DACs](#CompareDACs)
22
+
It is a good practice to review the contents of a DAC package before deploying it in production, and to validate the upgrade actions before upgrading an existing DAC. This is especially true when deploying packages that were not developed in your organization.
27
23
28
-
## <aname="Prerequisites"></a> Prerequisites
29
-
We recommend that you do not deploy a DAC package from unknown or untrusted sources. Such DACs could contain malicious code that might execute unintended [!INCLUDE[tsql](../../includes/tsql-md.md)] code or cause errors by modifying the schema. Before you use a DAC from an unknown or untrusted source, deploy it on an isolated test instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)], run [DBCC CHECKDB (Transact-SQL)](../../t-sql/database-console-commands/dbcc-checkdb-transact-sql.md) on the database, and also examine the code, such as stored procedures or other user-defined code, in the database.
24
+
Methods to upgrade a DAC package include:
25
+
-[View the Contents of a DAC](#ViewDACContents)
26
+
-[View Database Changes](#ViewDBChanges)
27
+
-[View Upgrade Actions](#ViewUpgradeActions)
28
+
-[Compare DACs](#CompareDACs)
29
+
30
+
## Untrusted DAC packages
31
+
We recommend that you do not deploy a DAC package from unknown or untrusted sources. Such DACs could contain malicious code that might execute unintended [!INCLUDE[tsql](../../includes/tsql-md.md)] code or cause errors by modifying the schema. Before you use a DAC from an unknown or untrusted source, deploy it on an isolated test instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)], run [DBCC CHECKDB (Transact-SQL)](../../t-sql/database-console-commands/dbcc-checkdb-transact-sql.md) on the database, and also examine the code, such as stored procedures or other user-defined code, in the database.
30
32
31
33
## <aname="ViewDACContents"></a> View the Contents of a DAC
32
-
There are two mechanisms for viewing the contents of a data-tier application (DAC) package. You can import the DAC package to a DAC project in SQL Server Developer Tools. You can unpack the contents of the package to a folder.
33
-
34
-
**View a DAC in SQL Server Developer Tools**
35
-
34
+
There are two mechanisms for viewing the contents of a data-tier application (DAC) package:
35
+
- import the DAC package to a SQL project in SQL Server Developer Tools
36
+
- publish the DAC package to a test instance
37
+
38
+
### Import a DAC in SQL Server Developer Tools
39
+
36
40
1. Open the **File** menu, select **New**, and then select **Project...**.
37
-
38
-
2. Select the **SQL Server** project template, and specify a **Name**, **Location**, and **Solution name**.
39
-
40
-
3. In **Solution Explorer**, right click the project node and select **Properties...**.
41
+
42
+
2. Select the **SQL Server** project template, and specify a **Name**, **Location**, and **Solution name**.
43
+
44
+
3. In **Solution Explorer**, right click the project node and select **Properties...**.
41
45
42
46
4. On the **Project Settings** tab, in the **Output Types** section, select the **Data-tier Application (.dacpac File)** check box, and then close the properties dialog.
43
-
47
+
44
48
5. In **Solution Explorer**, right click the project node and select **Import Data-tier Application...**.
45
-
49
+
46
50
6. Use **Solution Explorer** to open all of the files in the DAC, such as the server selection policy and the pre- and post-deployment scripts.
47
-
51
+
48
52
7. Use the **Schema View** to review all of the objects in the schema, particularly reviewing the code in objects such as functions or stored procedures.
49
53
50
-
**View a DAC in a Folder**
51
-
52
-
- Unpack the DAC package into a folder by following the instructions in [Unpack a DAC Package](../../relational-databases/data-tier-applications/unpack-a-dac-package.md).
53
-
54
-
- View the contents of the [!INCLUDE[tsql](../../includes/tsql-md.md)] scripts by opening them in the [!INCLUDE[ssDE](../../includes/ssde-md.md)] Query Editor in [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)].
55
-
56
-
- View the contents of the text files in tools such as notepad.
After the current version of a DAC was deployed to production, changes may have been made directly to the associated database that might conflict with the schema defined in a new version of the DAC. Before upgrading to a new version of the DAC, check to see if such changes have been made to the database.
54
+
### Publish the DAC package to a test instance
55
+
Multiple tools are available to publish a DAC package to a test instance. The [SQL Server Dacpac extension](../../azure-data-studio/extensions/sql-server-dacpac-extension.md) for Azure Data Studio contains the **Data-tier Application Wizard**. We will walk through publishing a DAC package to a test instance.
56
+
57
+
1. If needed, deploy a test instance using the [deployment wizard](../../azure-data-studio/deploy-sql-container.md).
58
+
59
+
2. Connect to your test instance in Azure Data Studio and right-click on the server node. Select **Data-tier application wizard** from the context menu.
60
+
61
+
3. On step 1 of the wizard, select **Deploy a data-tier application .dacpac file to an instance of SQL Server**
62
+
63
+
4. One step 2 of the wizard, input the file location and select **New Database** for target database. Enter a database name.
64
+
65
+
5. On step 3 of the wizard, review the summary before selecting **Deploy**.
66
+
67
+
6. Once the deployment has completed, review the contents of the database in object explorer.
68
+
69
+
7. OPTIONAL: Right-click the database in object explorer and select **Create project from database** to generate a SQL project from the database.
After the current version of a DAC was deployed to production, changes may have been made directly to the associated database that might conflict with the schema defined in a new version of the DAC. Before upgrading to a new version of the DAC, check to see if such changes have been made to the database.
73
+
Under several scenarios you may want to view the difference between a database and a DAC package. For example, changes may have been made directly to the associated database that might conflict with the schema defined in a new version of the DAC.
74
+
75
+
### All databases
76
+
**View database changes by using schema compare**
77
+
- Using the [Schema Compare extension in Azure Data Studio](/sql/azure-data-studio/extensions/schema-compare-extension#compare-schemas), the schema differences between an existing *.dacpac* and a database or two of the same can be viewed on Windows, macOS, and Linux.
78
+
79
+
- Using [SQL Server Data Tools in Visual Studio](../../ssdt/how-to-use-schema-compare-to-compare-different-database-definitions.md), the schema differences between an existing *.dacpac* and a database or two of the same can be viewed on Windows.
80
+
81
+
**View database changes by using SqlPackage CLI**
82
+
83
+
The SqlPackage CLI can be used with the [DeployReport action](../../tools/sqlpackage/sqlpackage-deploy-drift-report.md) to view the differences between a *.dacpac* and a database through the actions that would be taken if the *.dacpac* were published to the database.
84
+
85
+
### Databases registered as a data-tier application
86
+
**View database changes by using a wizard**
62
87
63
88
1. Run the **Upgrade Data-tier Application** wizard, specifying the currently deployed DAC and the DAC package containing the new version of the DAC.
64
89
@@ -68,22 +93,19 @@ ms.author: wiassaf
68
93
69
94
4. For more information on using the wizard, see [Upgrade a Data-tier Application](../../relational-databases/data-tier-applications/upgrade-a-data-tier-application.md).
70
95
71
-
**View Database Changes by Using PowerShell**
72
-
73
-
1. Create a SMO Server object and set it to the instance that contains the DAC to be viewed.
74
-
75
-
2. Open a **ServerConnection** object and connect to the same instance.
76
-
77
-
3. Specify the DAC name in a variable.
78
-
96
+
**View database changes by using PowerShell**
97
+
98
+
1. Create a SMO Server object and set it to the instance that contains the DAC to be viewed.
99
+
100
+
2. Open a **ServerConnection** object and connect to the same instance.
101
+
102
+
3. Specify the DAC name in a variable.
103
+
79
104
4. Use the **GetDatabaseChanges()** method to retrieve a **ChangeResults** object, and pipe the object to a text file to generate a simple report of new, deleted, and changed objects.
80
-
81
-
### View Database Changes Example (PowerShell)
82
-
**View Database Changes Example (PowerShell)**
83
-
84
-
The following example reports any database changes that have been made in a deployed DAC named MyApplicaiton.
85
-
86
-
```
105
+
106
+
The following example reports any database changes that have been made in a deployed DAC named MyApplication.
107
+
108
+
```powershell
87
109
## Set a SMO Server object to the default instance on the local computer.
The SqlPackage CLI can be used with the [DriftReport action](../../tools/sqlpackage/sqlpackage-deploy-drift-report.md) to view the changes that were made to a database since it was last registered.
**View database changes by using SQL project publish**
134
+
- Using the [SQL Database Projects extension in Azure Data Studio](/sql/azure-data-studio/extensions/sql-database-project-extension-build), the actions to be taken when a SQL project will be published to a database can be viewed on Windows, macOS, and Linux by selecting "Generate Script" during the publish process.
135
+
136
+
- Using [SQL Server Data Tools in Visual Studio](/sql/ssdt/how-to-change-target-platform-and-publish-a-database-project#to-publish-a-database-project), the actions to be taken when a SQL project will be published to a database can be viewed on Windows as a deployment script.
137
+
138
+
**View upgrade actions by using SqlPackage CLI**
139
+
The SqlPackage CLI can be used with the [DeployReport action](../../tools/sqlpackage/sqlpackage-deploy-drift-report.md) to view the differences between a *.dacpac* and a database through the actions that would be taken if the *.dacpac* were published to the database.
140
+
141
+
### Databases registered as a data-tier application
104
142
Before using a new version of a DAC package to upgrade a DAC that was deployed from an earlier DAC package, you can generate a report that contains the [!INCLUDE[tsql](../../includes/tsql-md.md)] statements that will be run during the upgrade, and then review the statements.
105
143
106
-
**Report Upgrade Actions by Using a Wizard**
144
+
**Report upgrade actions by using a wizard**
107
145
108
146
1. Run the **Upgrade Data-tier Application** wizard, specifying the currently deployed DAC and the DAC package containing the new version of the DAC.
4. For more information on using the wizard, see [Upgrade a Data-tier Application](../../relational-databases/data-tier-applications/upgrade-a-data-tier-application.md).
115
153
116
-
**Report Upgrade Actions by Using PowerShell**
154
+
**Report upgrade actions by using PowerShell**
117
155
118
156
1. Create a SMO Server object and set it to the instance that contains the deployed DAC.
5. Use the **GetIncrementalUpgradeScript()** method to get a list of the Transact-SQL statements an upgrade would run, and pipe the list to a text file.
127
165
128
166
6. Close the file stream used to read the DAC package file.
167
+
129
168
130
-
### View Upgrade Actions Example (PowerShell)
131
-
**View Upgrade Actions Example (PowerShell)**
132
-
133
-
The following example reports the Transact-SQL statements that would be run to upgrading a DAC named MyApplicaiton to the schema defined in a MyApplication2017.dacpac file.
169
+
The following example reports the Transact-SQL statements that would be run to upgrading a DAC named MyApplication to the schema defined in a MyApplication2017.dacpac file.
134
170
135
171
```
136
172
## Set a SMO Server object to the default instance on the local computer.
0 commit comments