I'm getting an odd error, when trying to create a connection to a azure sql database, through my azure function (Python & consumption). It all works locally, but no once deployed.
The error:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body {font-family:Arial; margin-left:40px; }img { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Service unavailable</title></head><body><div id='content'><div id='message'><h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p></div><div id='errorref'><span>[Some Long Code]=</span></div></div></body></html>
The Code:
import logging
import pyodbc
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
error = ''
try:
BB_connection = 'Driver={ODBC Driver 17 for SQL Server};Server=[server]\[instance];Database=[database];Trusted_Connection=yes;'
cnxn = pyodbc.connect(BB_connection)
except Exception as e:
error = str(e)
return func.HttpResponse(f"Error: {error}")
in requirements.txt I have added pyodbc==4.0.31 I've tried looking around, but have not been able to find, a question where someone else, gets the same output.
Is there some link between my azure sql data base and the azure function, that has to be established? I'm just wondering why, it works locally, but not once deployed.








