Azure功能数据库连接 [英] Azure Function Database Connection

查看:129
本文介绍了Azure功能数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python软件包,可以在Azure数据科学虚拟机上成功运行。但是,当我将其作为功能推送到Azure时,无法成功建立数据库连接。我收到一个错误消息,即不支持用于SQL Server的ODBC驱动程序13,因此我将驱动程序更改为用于SQL Server的ODBC驱动程序17,现在我没有收到错误,但是我知道的查询没有返回任何数据应该返回数据。

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.

还有其他原因导致无法返回数据吗?防火墙问题?我需要添加绑定吗?我是否需要分离连接字符串以将每个部分(例如,驱动程序,UID,PWD)分别输入 pyodbc.connect()?现在,我这样输入它:

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(设置)

此当我使用此代码在VM上运行数据时,查询可以很好地返回数据,而不能作为函数。

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

(请注意,这与我的上一篇关于阅读Azure应用设置的帖子(该问题已解决)。

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

推荐答案

原来这不是我认为的数据库连接问题;这是一个代码错误。

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

这篇关于Azure功能数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆