我正在尝试使用 ActiveDirectoryMSI 身份验证从用于 python 的 Azure 函数连接 Azure SQL 数据库。
请检查以下代码:-
import logging
from . import hy_param
import sys
import pyodbc
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
try:
connection = pyodbc.connect('driver={%s};server=%s;database=%s;Authentication=ActiveDirectoryMSI' % (hy_param.sql_driver, hy_param.server_name, hy_param.database_name))
sql_db = connection.cursor()
logging.info("MSSQL Database Connected")
except Exception as e:
return func.HttpResponse(f"Error in sql database connection : {e}", status_code=400)
sys.exit()
return func.HttpResponse(
"Database Connected",
status_code=200
)
请检查以下错误:-
Error in sql database connection : ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate] (-1) (SQLDriverConnect)')
有什么方法可以使用 ActiveDirectoryMSI 从 Azure 函数连接 Azure、SQL 数据库?
千万里不及你
拉丁的传说
相关分类