Connecting to Azure SQL Edge (local docker instance) from another network machine

Sunraj sharma 65 Reputation points
2023-09-27T00:00:40.93+00:00

Hi

I have a local instance of Azure SQL edge running (using docker on MacBook).

I am trying to connect to the server, with using pyodbc (in google colab), but i keep getting this error: Screenshot 2023-09-26 at 7.51.01 PM

I already followed this document: https://learn.microsoft.com/en-us/azure/azure-sql-edge/connect

I am fairly new to this, therefore my process of connecting is 2 lined:

  1. I run the docker container, and
  2. Then try to connect using pyodbc.

I am using IP Address and Port number from Networks (key in JSON structure) in docker

  1. Using IP address found here: Screenshot 2023-09-26 at 7.53.24 PM
  2. Using Host port number found here: Ports being used
Azure SQL Edge
Azure SQL Edge
An Azure service that provides a small-footprint, edge-optimized data engine with built-in artificial intelligence. Previously known as Azure SQL Database Edge.
48 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 15,501 Reputation points
    2023-09-27T08:51:39.3366667+00:00

    Hi Sunraj sharma •,

    Welcome to Microsoft Q&A forum and thanks for using Azure Services.

    As I understand, you want to Connect to Azure SQL Edge (local docker instance) from another network machine.

    I assume you are following the steps as below:

    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:

    import pyodbc
    server = '192.168.2.121,1600' # Replace this with the actual name or IP address of your SQL Edge Docker container
    username = 'sa' # SQL Server username
    password = 'MyStrongestP@ssword' # Replace this with the actual SA password from your deployment
    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.
    db_connection_string = "Driver={ODBC Driver 17 for SQL Server};Server=" + server + ";Database=" + database + ";UID=" + username + ";PWD=" + password + ";"
    conn = pyodbc.connect(db_connection_string, autocommit=True)
    
    

    Let us know if above steps are performed fine at your end.

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.