0

I have a Python package that I am able to run successfully on an Azure Data Science Virtual Machine. However, when I push it to Azure as a Function, I cannot successfully make a database connection. I was getting an error that the ODBC Driver 13 for SQL Server was not supported, so I changed the driver to ODBC Driver 17 for SQL Server and now I am NOT getting an error, but no data is being returned for a query that I know should return data.

Is there any other reason that data would not be returned? Firewall issues? do I need to add a binding? Do I need to separate out the connection string to feed each part (e.g., Driver, UID, PWD) into pyodbc.connect() separately? Right now I am feeding it in like this:

setting = os.environ("CONNECTIONSTRING")

conn = pyodbc.connect(setting)

This query works fine returning data when I run it on the VM using this code, just not as a Function.

(Note, this is different from my previous post regarding reading the Azure App Setting. That problem has been solved).

2 Answers 2

0

There are many parts where this could be breaking.

I'd suggest start by having a Profiler or Extended Events trace on your SQL Server to verify whether a connection is even being established. If not then you need to work through the the various points of connectivity to find out where it breaks. The identity, firewall, NSGs etc might all come into play here.

Once you see a connection then you can play with permissions to ensure that your query then returns your data.

Without a full picture of your infrastructure and settings it is hard to pin it down further.

Sign up to request clarification or add additional context in comments.

Comments

0

Turns out it was not a database connectivity issue like I thought it was; it was a code error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.