Access azure sql database within iotedge module

Newbie 41 Reputation points
2021-02-08T09:19:50.817+00:00

I have successfully query azure sql database on raspberry(through ssh) and other ides on my laptop.
My code:
import pymssql
conn = pymssql.connect(server='t***r.database.windows.net', user='@', password='', database=')
cursor = conn.cursor()
cursor.execute('SELECT * FROM Persons')
for row in cursor:
print ("Inserted Product ID : " +str(row))
print("done")
conn.close()

However, same piece of codes when i added to the SampleModule and deployed to iotedge device(raspberry) made my SampleModule stuck in backoff state(others were running normally). When i inspected the logs, i found this error: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (***.database.windows.net:1433)\nNet-Lib error during Connection timed out (110)\n')

What i have done before the error:

  • i have run successfully SampleModule without the above piece of codes before
  • i have binded port 1433
  • i set azure sql server firewall 0.0.0.0 to 255.255.255.255 for testing purpose so i doubt it is the problem
  • In dockerfile, i only added RUN apt-get --assume-yes update and everything was smooth until the module actually ran on my raspberry
    RUN apt-get --assume-yes install freetds-dev freetds-bin gcc
    RUN pip install pymssql
Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
545 questions
Azure SQL Database
{count} votes