pyodbc.connect() 首次尝试从 Azure 函数连接到 Azure SQL 时失败
pyodbc.connect() fails on first try to connect to Azure SQL from Azure function
我正在尝试使用带有令牌身份验证的 pyodbc.connect() 从 Azure 函数连接到 Azure SQL。 Azure SQL 数据库配置了自动暂停。如果我在 SQL 数据库有 'paused' 之后调用我的 Azure 函数,第一次尝试总是失败。
我尝试将超时参数添加到pyodbc.connect(),超时=60,但我仍然运行出错,例如:
('HY000', "[HY000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Database '<DB_NAME>' on server
'<SERVER_NAME>.database.windows.net' is not currently available. Please retry the connection later. If
the problem persists, contact customer support, and provide them the session tracing ID of
'{<TRACKING_ID>}'. (40613) (SQLDriverConnect)")
如何确保我对 Azure SQL 的第一次调用不会失败?
正如您所说,如果您的数据库已暂停,我们将无法访问它。
我们无法确保您对 Azure SQL 的首次调用不会在不知道数据库状态的情况下失败。想法或解决方案是正确的,您需要在 运行 Azure Function 之前首先发送连接请求以唤醒 SQL DB,然后该函数可以无错误地连接到 Azure SQL DB。
HTH.
我正在尝试使用带有令牌身份验证的 pyodbc.connect() 从 Azure 函数连接到 Azure SQL。 Azure SQL 数据库配置了自动暂停。如果我在 SQL 数据库有 'paused' 之后调用我的 Azure 函数,第一次尝试总是失败。
我尝试将超时参数添加到pyodbc.connect(),超时=60,但我仍然运行出错,例如:
('HY000', "[HY000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Database '<DB_NAME>' on server
'<SERVER_NAME>.database.windows.net' is not currently available. Please retry the connection later. If
the problem persists, contact customer support, and provide them the session tracing ID of
'{<TRACKING_ID>}'. (40613) (SQLDriverConnect)")
如何确保我对 Azure SQL 的第一次调用不会失败?
正如您所说,如果您的数据库已暂停,我们将无法访问它。
我们无法确保您对 Azure SQL 的首次调用不会在不知道数据库状态的情况下失败。想法或解决方案是正确的,您需要在 运行 Azure Function 之前首先发送连接请求以唤醒 SQL DB,然后该函数可以无错误地连接到 Azure SQL DB。
HTH.