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
description: Learn how to connect to and query Azure SQL Edge.
4
4
author: rwestMSFT
5
5
ms.author: randolphwest
6
-
ms.reviewer: randolphwest
7
-
ms.date: 07/25/2020
6
+
ms.date: 07/28/2023
8
7
ms.service: sql-edge
9
8
ms.topic: conceptual
10
-
services: sql-edge
11
9
---
12
-
13
10
# Connect and query Azure SQL Edge
14
11
15
12
In Azure SQL Edge, after you deploy a container, you can connect to the database engine from any of the following locations:
@@ -23,14 +20,15 @@ In Azure SQL Edge, after you deploy a container, you can connect to the database
23
20
24
21
You can connect to an instance of Azure SQL Edge instance from any of these common tools:
25
22
26
-
*[sqlcmd](/sql/linux/sql-server-linux-setup-tools): sqlcmd client tools are already included in the container image of Azure SQL Edge. If you attach to a running container with an interactive bash shell, you can run the tools locally. SQL client tools are NOT available on the ARM64 platform, as such they are not included in the ARM64 version of the SQL Edge containers.
27
-
*[SQL Server Management Studio](/sql/ssms/sql-server-management-studio-ssms)
28
-
*[Azure Data Studio](/sql/azure-data-studio/download-azure-data-studio)
29
-
*[Visual Studio Code](/sql/visual-studio-code/sql-server-develop-use-vscode)
23
+
-[sqlcmd](/sql/linux/sql-server-linux-setup-tools): **sqlcmd** client tools are already included in the container image of Azure SQL Edge. If you attach to a running container with an interactive bash shell, you can run the tools locally. SQL client tools *aren't*available on the ARM64 platform.
24
+
-[SQL Server Management Studio](/sql/ssms/sql-server-management-studio-ssms)
25
+
-[Azure Data Studio](/sql/azure-data-studio/download-azure-data-studio)
26
+
-[Visual Studio Code](/sql/visual-studio-code/sql-server-develop-use-vscode)
30
27
31
-
To connect to an Azure SQL Edge database engine from a network machine, you need the following:
28
+
To connect to an Azure SQL Edge Database Engine from a network machine, you need the following:
32
29
33
30
-**IP Address or network name of the host machine**: This is the host machine where the Azure SQL Edge container is running.
31
+
34
32
-**Azure SQL Edge container host port mapping**: This is the mapping for the Docker container port to a port on the host. Within the container, Azure SQL Edge is always mapped to port 1433. You can change this if you want to. To change the port number, update the **Container Create Options** for the Azure SQL Edge module in Azure IoT Edge. In the following example, port 1433 on the container is mapped to port 1600 on the host.
35
33
36
34
```JSON
@@ -47,69 +45,64 @@ To connect to an Azure SQL Edge database engine from a network machine, you need
47
45
48
46
- **SA password for the Azure SQL Edge instance**: This is the value specified for the `SA_PASSWORD` environment variable during deployment of Azure SQL Edge.
49
47
50
-
## Connect to the database engine from within the container
48
+
## Connect to the Database Engine from within the container
51
49
52
-
The [SQL Server command-line tools](/sql/linux/sql-server-linux-setup-tools) are included in the container image of Azure SQL Edge. If you attach to the container with an interactive command prompt, you can run the tools locally. SQL client tools are NOT available on the ARM64 platform, as such they are not included in the ARM64 version of the SQL Edge containers.
50
+
The [SQL Server command-line tools](/sql/linux/sql-server-linux-setup-tools) are included in the container image of Azure SQL Edge. If you attach to the container with an interactive command prompt, you can run the tools locally. SQL client tools aren't available on the ARM64 platform.
53
51
54
52
1. Use the `docker exec -it` command to start an interactive bash shell inside your running container. In the following example, `e69e056c702d` is the container ID.
55
53
56
-
```bash
57
-
docker exec -it <Azure SQL Edge container ID or name> /bin/bash
58
-
```
54
+
```bash
55
+
docker exec -it e69e056c702d /bin/bash
56
+
```
59
57
60
-
> [!TIP]
61
-
> You don't always have to specify the entire container ID. You only have to specify enough characters to uniquely identify it. So in this example, it might be enough to use `e6` or `e69`, rather than the full ID.
58
+
> [!TIP]
59
+
> You don't always have to specify the entire container ID. You only have to specify enough characters to uniquely identify it. So in this example, it might be enough to use `e6` or `e69`, rather than the full ID.
62
60
63
-
2. When you're inside the container, connect locally with sqlcmd. Sqlcmd isn't in the path by default, so you have to specify the full path.
61
+
1. When you're inside the container, connect locally with **sqlcmd**. **sqlcmd** isn't in the path by default, so you have to specify the full path.
64
62
65
-
```bash
66
-
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourPassword>'
67
-
```
63
+
```bash
64
+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourPassword>'
65
+
```
68
66
69
-
3. When you're finished with sqlcmd, type `exit`.
67
+
1. When you're finished with **sqlcmd**, type `exit`.
70
68
71
-
4. When you're finished with the interactive command prompt, type `exit`. Your container continues to run after you exit the interactive bash shell.
69
+
1. When you're finished with the interactive command prompt, type `exit`. Your container continues to run after you exit the interactive bash shell.
72
70
73
71
## Connect to Azure SQL Edge from another container on the same host
74
72
75
73
Because two containers that are running on the same host are on the same Docker network, you can easily access them by using the container name and the port address for the service. For example, if you're connecting to the instance of Azure SQL Edge from another Python module (container) on the same host, you can use a connection string similar to the following. (This example assumes that Azure SQL Edge is configured to listen on the default port.)
76
74
77
75
```python
78
-
79
76
import pyodbc
80
77
server ='MySQLEdgeContainer'# Replace this with the actual name of your SQL Edge Docker container
81
78
username ='sa'# SQL Server username
82
79
password ='MyStrongestP@ssword'# Replace this with the actual SA password from your deployment
83
80
database ='MyEdgeDatabase'# Replace this with the actual database name from your deployment. If you do not have a database created, you can use Master database.
84
81
db_connection_string ="Driver={ODBC Driver 17 for SQL Server};Server="+ server +";Database="+ database +";UID="+ username +";PWD="+ password +";"
## Connect to Azure SQL Edge from another network machine
90
86
91
-
You might want to connect to the instance of Azure SQL Edge from another machine on the network. To do so, use the IP address of the Docker host and the host port to which the Azure SQL Edge container is mapped. For example, if the IP address of the Docker host is *xxx.xxx.xxx.xxx*, and the Azure SQL Edge container is mapped to host port *1600*, then the server address for the instance of Azure SQL Edge would be *xxx.xxx.xxx.xxx,1600*. The updated Python script is:
87
+
You might want to connect to the instance of Azure SQL Edge from another machine on the network. To do so, use the IP address of the Docker host and the host port to which the Azure SQL Edge container is mapped. For example, if the IP address of the Docker host is `192.168.2.121`, and the Azure SQL Edge container is mapped to host port *1600*, then the server address for the instance of Azure SQL Edge would be `192.168.2.121,1600`. The updated Python script is:
92
88
93
89
```python
94
-
95
90
import pyodbc
96
-
server ='xxx.xxx.xxx.xxx,1600'# Replace this with the actual name of your SQL Edge Docker container
91
+
server ='192.168.2.121,1600'# Replace this with the actual name or IP address of your SQL Edge Docker container
97
92
username ='sa'# SQL Server username
98
93
password ='MyStrongestP@ssword'# Replace this with the actual SA password from your deployment
99
94
database ='MyEdgeDatabase'# Replace this with the actual database name from your deployment. If you do not have a database created, you can use Master database.
100
95
db_connection_string ="Driver={ODBC Driver 17 for SQL Server};Server="+ server +";Database="+ database +";UID="+ username +";PWD="+ password +";"
To connect to an instance of Azure SQL Edge by using SQL Server Management Studio running on a Windows machine, see [SQL Server Management Studio](/sql/linux/sql-server-linux-manage-ssms).
106
100
107
-
To connect to an instance of Azure SQL Edge by using Visual Studio Code on a Windows, Mac or Linux machine, see [Visual Studio Code](/sql/visual-studio-code/sql-server-develop-use-vscode).
101
+
To connect to an instance of Azure SQL Edge by using Visual Studio Code on a Windows, macOS or Linux machine, see [Visual Studio Code](/sql/visual-studio-code/sql-server-develop-use-vscode).
108
102
109
-
To connect to an instance of Azure SQL Edge by using Azure Data Studio on a Windows, Mac or Linux machine, see [Azure Data Studio](/sql/azure-data-studio/quickstart-sql-server).
103
+
To connect to an instance of Azure SQL Edge by using Azure Data Studio on a Windows, macOS or Linux machine, see [Azure Data Studio](/sql/azure-data-studio/quickstart-sql-server).
110
104
111
105
## Next steps
112
106
113
-
[Connect and query](/sql/linux/sql-server-linux-configure-docker#connect-and-query)
114
-
115
-
[Install SQL Server tools on Linux](/sql/linux/sql-server-linux-setup-tools)
107
+
-[Connect and query](/sql/linux/sql-server-linux-configure-docker#connect-and-query)
108
+
-[Install SQL Server tools on Linux](/sql/linux/sql-server-linux-setup-tools)
0 commit comments