In tenant1
Azure Function, there is a Python function to connect to an Azure SQL database:
import aioodbc
import logging
async def create_db_connection(SERVER_NAME: str, DATABASE_NAME: str, USERNAME: str, PASSWORD: str) -> aioodbc.Connection:
CONNECTION_STRING = (
'Driver={ODBC Driver 17 for SQL Server};'
f'Server=tcp:{SERVER_NAME}.database.windows.net,1433;'
f'Database={DATABASE_NAME};Uid={USERNAME};Pwd={PASSWORD};'
'Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;'
)
conn = await retry(aioodbc.connect, dsn=CONNECTION_STRING, autocommit=True)
logging.info(f'##### Azure SQL Server connection successfully created')
return conn
Is it possible to use tenant2
's SERVER_NAME
, DATABASE_NAME
, USERNAME
and PASSWORD
to connect to the database?
Or is there more to it than that?