Skip to content

Commit e0ece86

Browse files
authored
Merge pull request #246640 from rwestMSFT/rw-0728-sql-edge-fix-112758
Refresh Azure SQL Edge connect article and include PR 112758
2 parents 892e5f2 + 779efd9 commit e0ece86

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

articles/azure-sql-edge/connect.md

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ title: Connect and query Azure SQL Edge
33
description: Learn how to connect to and query Azure SQL Edge.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.reviewer: randolphwest
7-
ms.date: 07/25/2020
6+
ms.date: 07/28/2023
87
ms.service: sql-edge
98
ms.topic: conceptual
10-
services: sql-edge
119
---
12-
1310
# Connect and query Azure SQL Edge
1411

1512
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
2320

2421
You can connect to an instance of Azure SQL Edge instance from any of these common tools:
2522

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)
3027

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:
3229

3330
- **IP Address or network name of the host machine**: This is the host machine where the Azure SQL Edge container is running.
31+
3432
- **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.
3533

3634
```JSON
@@ -47,69 +45,64 @@ To connect to an Azure SQL Edge database engine from a network machine, you need
4745

4846
- **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.
4947

50-
## Connect to the database engine from within the container
48+
## Connect to the Database Engine from within the container
5149

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.
5351

5452
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.
5553

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+
```
5957

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.
6260
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.
6462

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+
```
6866

69-
3. When you're finished with sqlcmd, type `exit`.
67+
1. When you're finished with **sqlcmd**, type `exit`.
7068

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.
7270

7371
## Connect to Azure SQL Edge from another container on the same host
7472

7573
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.)
7674

7775
```python
78-
7976
import pyodbc
8077
server = 'MySQLEdgeContainer' # Replace this with the actual name of your SQL Edge Docker container
8178
username = 'sa' # SQL Server username
8279
password = 'MyStrongestP@ssword' # Replace this with the actual SA password from your deployment
8380
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.
8481
db_connection_string = "Driver={ODBC Driver 17 for SQL Server};Server=" + server + ";Database=" + database + ";UID=" + username + ";PWD=" + password + ";"
8582
conn = pyodbc.connect(db_connection_string, autocommit=True)
86-
8783
```
8884

8985
## Connect to Azure SQL Edge from another network machine
9086

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:
9288

9389
```python
94-
9590
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
9792
username = 'sa' # SQL Server username
9893
password = 'MyStrongestP@ssword' # Replace this with the actual SA password from your deployment
9994
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.
10095
db_connection_string = "Driver={ODBC Driver 17 for SQL Server};Server=" + server + ";Database=" + database + ";UID=" + username + ";PWD=" + password + ";"
10196
conn = pyodbc.connect(db_connection_string, autocommit=True)
102-
10397
```
10498

10599
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).
106100

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).
108102

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).
110104

111105
## Next steps
112106

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

Comments
 (0)